Hi I’m trying to make a table with two groups of subjects over 4 time points, but I think there is an error with my code that I’m not figuring out.
tbl <- df_5%>%
group_by(outcome) %>%
select(outcome, time_nrp, lac, ast, alt, bf, do2, vo2) %>%
mutate(outcome = case_when(outcome == "0" ~ "Discarded",
outcome == "1" ~ "Transplanted")) %>%
mutate(time_nrp = case_when(time_nrp == "0" ~ "0",
time_nrp == "1" ~ "1",
time_nrp == "2" ~ "2",
time_nrp == "3" ~ "3",
time_nrp == "4" ~ "4")) %>%
mutate(time_nrp = paste(time_nrp, "NRP time point"),
outcome = factor(outcome, labels = c("Discarded", "Transplanted")))%>%
tbl_strata(
strata = time_nrp,
~.x %>%
tbl_summary(by = outcome,
type = where(is.numeric) ~ "continuous",
statistic = list(all_continuous() ~ "{median} ({p25}, {p75})",
all_categorical() ~ "{n} / {N} ({p}%)"),
digits = list (all_continuous ~ 2),
label = list (lac ~ "Lactaate mmol/l",
ast ~ "AST (U/I)",
alt ~ "ALT (U/I)",
bf ~ "Blood Flow (l/min)",
do2 ~ "DO2 (ml/min)",
vo2 ~ "VO2 (ml/min)"),
missing = "no")%>%
modify_header(all_stat_cols() ~ "**{level}**", label = "**Characteristics**")) %>%
add_p(test = list(c("lac", "ast", "alt", "bf",
"do2", "vo2") ~ "wilcox.test"))%>%
as_gt() %>%
gt::tab_header(title = "Table 2")
any idea how i can fix it?
New contributor
Irene Steinberg is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.