Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When pattern manages NAs in fmt_icon() |> cols_merge(), NA gets repeatedly appended to the value. #1880

Open
2 tasks done
JoFrhwld opened this issue Sep 15, 2024 · 0 comments

Comments

@JoFrhwld
Copy link

Prework

Description

After passing a table to fmt_icon(), if I then cols_merge() with a pattern that takes into account NAs, a very large number of NA get appended to cells that don't have NAs.

Reproducible example

library(gt)

data.frame(
  x = c("dice-one", "dice-two", "dice-three"),
  y = c("dice-one", NA, "dice-three")
) |> 
  gt() ->
  base_table

This works

Without using fmt_icon(), this works as expected.

base_table |> 
  cols_merge(
    columns = everything(),
    pattern = "({1}<< {2}>>)"
  )

blog_-drafting-_RStudio

This does not work

It also takes a while to run, I assume because of all the NAs that are getting appended.

base_table |> 
  fmt_icon() |> 
  cols_merge(
    columns = everything(),
    pattern = "({1}<< {2}>>)"
  )

blog_-drafting-_RStudio

Inspecting the html output for the first row, there were 49,547 NAs appended to the cell.

Expected result

I expected output similar to the working example, but with the icons instead of the names of the icons.

Session info

R version 4.4.0 (2024-04-24)
Platform: aarch64-apple-darwin20
Running under: macOS Sonoma 14.2

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.4-arm64/Resources/lib/libRlapack.dylib;  LAPACK version 3.12.0

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 datasets  utils     methods   base     

other attached packages:
[1] gt_0.11.0

loaded via a namespace (and not attached):
 [1] digest_0.6.37     utf8_1.2.4        R6_2.5.1          fastmap_1.2.0    
 [5] tidyselect_1.2.1  xfun_0.47         magrittr_2.0.3    glue_1.7.0       
 [9] tibble_3.2.1      knitr_1.48        htmltools_0.5.8.1 pkgconfig_2.0.3  
[13] dplyr_1.1.4       generics_0.1.3    lifecycle_1.0.4   xml2_1.3.6       
[17] cli_3.6.3         fansi_1.0.6       vctrs_0.6.5       withr_3.0.1      
[21] renv_1.0.7        compiler_4.4.0    rstudioapi_0.16.0 tools_4.4.0      
[25] pillar_1.9.0      rlang_1.1.4    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Backlog
Development

No branches or pull requests

2 participants