Eu estava fazendo um novo tema no gtsummary
pacote, mas parece que ele afeta a tbl_continuous
função, embora eu não tenha feito nenhum argumento sobre isso tbl_continuous
no meu tema. Além disso, não consigo encontrar na documentação nenhum elemento de tema específico para tbl_continuous
.
Aqui está meu código:
> my_theme = list(
+ "pkgwide-str:theme_name" = "JO JO",
+ "pkgwide-fn:pvalue_fun" = function(x) style_pvalue(x, digits = 2),
+ "pkgwide-fun:pre_conversion" = function(x) bold_labels(x),
+ "pkgwide-str:ci.sep" = "-",
+ #$ tbl_regression $#
+ "tbl_regression-str:ref_row_text" = "1(r)",
+ #$ tbl_summary $#
+ "tbl_summary-fn:percent_fun" = function(x) style_percent(x, symbol = T, digits = 1),
+ "tbl_summary-arg:statistic" = list(all_continuous() ~"{mean} ({sd})",
+ all_categorical() ~ "{n} ({p})"))
> check_gtsummary_theme(my_theme)
✔ Looks good!
> set_gtsummary_theme(my_theme)
Setting theme "JO JO"
> tbl_continuous(
+ data = trial,
+ variable = age,
+ by = trt,
+ include = grade
+ )
Error in `tbl_continuous()`:
! Problem with the `statistic` argument.
Error converting string "p" to a function.
ℹ Is the name spelled correctly and available?
Run `rlang::last_trace()` to see where the error occurred.
> rlang::last_trace()
<error/rlang_error>
Error in `tbl_continuous()`:
! Problem with the `statistic` argument.
Error converting string "p" to a function.
ℹ Is the name spelled correctly and available?
---
Backtrace:
▆
1. └─gtsummary::tbl_continuous(data = trial, variable = age, by = trt, include = grade)
Run rlang::last_trace(drop = FALSE) to see 27 hidden frames.
> rlang::last_trace(drop = FALSE)
<error/rlang_error>
Error in `tbl_continuous()`:
! Problem with the `statistic` argument.
Error converting string "p" to a function.
ℹ Is the name spelled correctly and available?
---
Backtrace:
▆
1. └─gtsummary::tbl_continuous(data = trial, variable = age, by = trt, include = grade)
2. ├─dplyr::bind_rows(...)
3. │ └─rlang::list2(...)
4. └─gtsummary:::map(...)
5. └─base::lapply(.x, .f, ...)
6. └─gtsummary (local) FUN(X[[i]], ...)
7. ├─cards::bind_ard(...)
8. │ └─dplyr::bind_rows(...)
9. │ └─rlang::list2(...)
10. ├─cards::ard_continuous(...)
11. ├─cards:::ard_continuous.data.frame(...)
12. │ ├─cards::process_formula_selectors(...)
13. │ └─cards:::process_formula_selectors.data.frame(...)
14. │ └─rlang::dots_list(...)
15. ├─rlang::set_names(...)
16. └─gtsummary:::.continuous_statistics_chr_to_fun(statistic)
17. └─base::lapply(...)
18. └─gtsummary (local) FUN(X[[i]], ...)
19. ├─rlang::set_names(...)
20. └─gtsummary:::map2(...)
21. └─base::mapply(.f, .x, .y, MoreArgs = list(...), SIMPLIFY = FALSE)
22. └─gtsummary (local) `<fn>`(dots[[1L]][[2L]], dots[[2L]][[2L]])
23. └─base::tryCatch(...)
24. └─base (local) tryCatchList(expr, classes, parentenv, handlers)
25. └─base (local) tryCatchOne(expr, names, parentenv, handlers[[1L]])
26. └─value[[3L]](cond)
27. └─cli::cli_abort(...)
28. └─rlang::abort(...)
> reset_gtsummary_theme()
> tbl_continuous(
+ data = trial,
+ variable = age,
+ by = trt,
+ include = grade
+ )
Quando eu reseto o tema, ele emite a tabela sem problemas. Quero saber onde está o problema e também por que não há elementos de tema específicos para tbl_continuous
.
Editar: Também tentei usar theme_gtsummary_mean_sd()
o built-in gtsummary
e o mesmo erro persiste.
> theme_gtsummary_mean_sd()
> trial |>
+ tbl_continuous(age)
Error in `tbl_continuous()`:
! Problem with the `statistic` argument.
Error converting string "p" to a function.
ℹ Is the name spelled correctly and available?
Run `rlang::last_trace()` to see where the error occurred.
Obrigado por postar. Houve um erro em que o tema estatístico tbl_summary estava sendo aplicado incorretamente a
tbl_continuous()
. A correção agora está ativa na versão dev do pacote. https://github.com/ddsjoberg/gtsummaryCriado em 2024-09-12 com reprex v2.1.0