Skip to content

gtsave() to DOCX encoding issue involving sub_small_vals #1997

Description

@chihyunkim

Prework

Description

The less-than sign generated by sub_small_vals is not encoded properly in the table exported to Word format via gtsave. (But the string < is properly represented if directly in the data.)

Reproducible example

library(tibble)
library(gt)

data <- tibble(x = c(0.001, 0.01, 0.1, 1), 
               y = c("<", "%", ">", "î"))

table <- data %>% 
  gt() %>% 
  sub_small_vals()

gtsave(table, "testfile.docx")

Output:

Image

Expected result

Expected:

Image

Session info

> sessionInfo()
R version 4.5.0 (2025-04-11)
Platform: aarch64-apple-darwin20
Running under: macOS Sonoma 14.7.3

Matrix products: default
BLAS:   /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib 
LAPACK: /Library/Frameworks/R.framework/Versions/4.5-arm64/Resources/lib/libRlapack.dylib;  LAPACK version 3.12.1

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

time zone: America/New_York
tzcode source: internal

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] gt_1.0.0     tibble_3.2.1

loaded via a namespace (and not attached):
 [1] digest_0.6.37     R6_2.6.1          fastmap_1.2.0     xfun_0.52         tidyselect_1.2.1  magrittr_2.0.3    glue_1.8.0       
 [8] knitr_1.50        pkgconfig_2.0.3   htmltools_0.5.8.1 rmarkdown_2.29    dplyr_1.1.4       generics_0.1.3    lifecycle_1.0.4  
[15] xml2_1.3.8        cli_3.6.4         sass_0.4.10       vctrs_0.6.5       withr_3.0.2       compiler_4.5.0    rstudioapi_0.17.1
[22] tools_4.5.0       evaluate_1.0.3    pillar_1.10.2     fs_1.6.6          rlang_1.1.6   

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions