Skip to content

column formatters cannot be used when rowname_col includes hyperlinks #1600

@jdjohn215

Description

@jdjohn215

Description

Thanks for the great package. I recently realized that when the table stub includes hyperlinks, using a column formatting function elsewhere in the table returns this error: Error in vars_validate(): ! vars must be a character vector.

Reproducible example

Here's a table with a markdown link in the name column.

df <- tibble(
  name = c("[BBC](https://www.bbc.com/news)", "[CNN](https://edition.cnn.com)"),
  country = c("UK", "US"),
  pct = c(0.75, 0.25))

This works:

df |>
  mutate(name = map(name, gt::md)) |>
  gt() |>
  fmt_percent(columns = pct)

So does this:

df |>
  mutate(name = map(name, gt::md)) |>
  gt(rowname_col = "name")

But this gives an error:

df |>
  mutate(name = map(name, gt::md)) |>
  gt(rowname_col = "name") |>
  fmt_percent(columns = pct)

Session info

Here's my session info. Thanks!

R version 4.3.2 (2023-10-31)
Platform: x86_64-apple-darwin20 (64-bit)
Running under: macOS Sonoma 14.2.1

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.3-x86_64/Resources/lib/libRlapack.dylib;  LAPACK version 3.11.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/Chicago
tzcode source: internal

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

other attached packages:
 [1] gt_0.10.1       lubridate_1.9.3 forcats_1.0.0   stringr_1.5.1   dplyr_1.1.4     purrr_1.0.2    
 [7] readr_2.1.5     tidyr_1.3.1     tibble_3.2.1    ggplot2_3.4.4   tidyverse_2.0.0

loaded via a namespace (and not attached):
 [1] sass_0.4.8        utf8_1.2.4        generics_0.1.3    xml2_1.3.6        stringi_1.8.3    
 [6] hms_1.1.3         digest_0.6.33     magrittr_2.0.3    grid_4.3.2        timechange_0.2.0 
[11] pkgload_1.3.4     fastmap_1.1.1     fansi_1.0.6       scales_1.3.0      cli_3.6.2        
[16] rlang_1.1.3       crayon_1.5.2      bit64_4.0.5       munsell_0.5.0     commonmark_1.9.0 
[21] withr_3.0.0       tools_4.3.2       parallel_4.3.2    tzdb_0.4.0        colorspace_2.1-0 
[26] vctrs_0.6.5       R6_2.5.1          lifecycle_1.0.4   bit_4.0.5         vroom_1.6.5      
[31] pkgconfig_2.0.3   pillar_1.9.0      gtable_0.3.4      glue_1.7.0        xfun_0.41        
[36] tidyselect_1.2.0  rstudioapi_0.15.0 knitr_1.45        htmltools_0.5.7   compiler_4.3.2   
[41] markdown_1.12    

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions