Open
Description
Reported here: https://stackoverflow.com/questions/79362375
library(magrittr)
gtsummary::tbl_summary(mtcars, statistic = all_continuous() ~ "\\makecell{{{mean}}}")
#> Error in `gtsummary::tbl_summary()`:
#> ! Error processing `statistic` argument.
#> ! Caused by error in `all_continuous()`: ! could not find function
#> "all_continuous"
#> ℹ Select among columns "mpg", "cyl", "disp", "hp", "drat", "wt", "qsec", "vs",
#> "am", "gear", and "carb"
.extract_glue_elements <- function(x) {
regmatches(x, gregexpr("\\{([^\\}]*)\\}", x)) |>
unlist() %>%
{substr(., 2, nchar(.) - 1)} # styler: off
}
.extract_glue_elements("\\makecell{mean}") # should return `c('mean')`
#> [1] "mean"
.extract_glue_elements("\\makecell{{mean}}") # should return `character(0L)`
#> [1] "{mean"
.extract_glue_elements("\\makecell{{{mean}}}") # should return `c('mean')`
#> [1] "{{mean"
# these will eventually be processed with glue()
glue::glue("{letters[1]}")
#> a
glue::glue("{{letters[1]}}")
#> {letters[1]}
glue::glue("{{{letters[1]}}}")
#> {a}
Created on 2025-01-16 with reprex v2.1.1
Metadata
Assignees
Labels
No labels