Open jaromilfrossard opened 6 days ago
Dear @jaromilfrossard , Thanks for the post.
Can you make a couple of updates/add more information?
tbl_summary(...) |> as_kable()
. For your use case, you may also need the reset_gtsummary_theme()
function to reset/remove themes.Hello,
The difference is in the display of the statistics. From my understanding the JAMA theme displays the statistics with the variable name (eg: "Class, n (%)") not as reference in the footnote.
However, this feature does not seem to apply with tbl_svysummary(). It is visible in the last kable, the "quoted" line is "|Class |NA |NA |", but I would expect "|Class, n (%) |NA |NA |".
I hope it is more clear now.
library(gtsummary)
#> Warning: package 'gtsummary' was built under R version 4.4.1
reset_gtsummary_theme()
# default theme
survey::svydesign(~1, data = as.data.frame(Titanic), weights = ~Freq) |>
tbl_svysummary(by = Survived, percent = "row", include = c(Class, Age)) |>
knitr::kable()
|Characteristic |No
N = 1,490 |Yes
N = 711 |
|:——————|:—————–|:—————-|
|Class |NA |NA |
|1st |122 (38%) |203 (62%) |
|2nd |167 (59%) |118 (41%) |
|3rd |528 (75%) |178 (25%) |
|Crew |673 (76%) |212 (24%) |
|Age |NA |NA |
|Child |52 (48%) |57 (52%) |
|Adult |1,438 (69%) |654 (31%) |
as.data.frame(Titanic)|>
tbl_summary(by = Survived, percent = "row", include = c(Class, Age)) |>
knitr::kable()
|Characteristic |No
N = 16 |Yes
N = 16 |
|:——————|:————–|:—————|
|Class |NA |NA |
|1st |4 (50%) |4 (50%) |
|2nd |4 (50%) |4 (50%) |
|3rd |4 (50%) |4 (50%) |
|Crew |4 (50%) |4 (50%) |
|Age |NA |NA |
|Child |8 (50%) |8 (50%) |
|Adult |8 (50%) |8 (50%) |
theme_gtsummary_journal("jama")
#> Setting theme "JAMA"
# Here it displays the statistics with the variable: "Class, n (%)"
as.data.frame(Titanic)|>
tbl_summary(by = Survived, percent = "row", include = c(Class, Age)) |>
knitr::kable()
|Characteristic |No
N = 16 |Yes
N = 16 |
|:——————|:————–|:—————|
|Class, n (%) |NA |NA |
|1st |4 (50) |4 (50) |
|2nd |4 (50) |4 (50) |
|3rd |4 (50) |4 (50) |
|Crew |4 (50) |4 (50) |
|Age, n (%) |NA |NA |
|Child |8 (50) |8 (50) |
|Adult |8 (50) |8 (50) |
# Here the statistic is not displayed: "Class, n (%)"
survey::svydesign(~1, data = as.data.frame(Titanic), weights = ~Freq) |>
tbl_svysummary(by = Survived, percent = "row", include = c(Class, Age)) |>
knitr::kable()
|Characteristic |No
N = 1,490 |Yes
N = 711 |
|:——————|:—————–|:—————-|
|Class |NA |NA |
|1st |122 (38) |203 (62) | |2nd |167 (59) |118 (41) | |3rd |528 (75) |178 (25) | |Crew |673 (76) |212 (24) | |Age |NA |NA | |Child |52 (48) |57 (52) | |Adult |1,438 (69) |654 (31) |
Created on 2024-09-13 with reprex v2.1.1
Ah, yes, I see now. Thank you for the report!
Hello,
Thank you for creating gtsummary!
It seems that the theme for journals does not apply correctly to the tbl_svysummary() object as it stays the default.
However, it seems that the "compact" theme worked as I expected.
I am using the last CRAN version of gtsummary (2.0.2), with R 4.4.0, on windows.
Thanks you again!
PROBLEM: default theme
OK : JAMA theme
PROBLEM: default + compact theme
OK: JAMA + compact theme