Great question and great answer! https://stackoverflow.com/users/12109788/jpsmith
I have added more variables in c() and I can't get it to sum the medians etc for each variable. Instead I get a list per hour from the first value. How can I fix this?
library(dplyr)
library(chron)
library(gtsummary)
chrontest <- chestdf %>%
select(tts_sec, ttl_sec, ttprov1_sec, deltatrop_sec, vistelse_sec) %>%
drop_na() %>%
mutate(across(ends_with("_sec"), ~ format(as.POSIXct(.), "%H:%M:%S"))) %>%
mutate(across(ends_with("_sec"), ~ chron::times(.)))
summary_table <- chrontest %>%
tbl_summary(
include = c("tts_sec", "ttl_sec", "ttprov1_sec", "deltatrop_sec", "vistelse_sec"),
label = list(
tts_sec ~ "Tid till S",
ttl_sec ~ "Tid till L",
ttprov1_sec ~ "Tid till provtagn 1",
deltatrop_sec ~ "Tid till provtagn 2",
vistelse_sec ~ "Vistelsetid"
),
type = list(
all_continuous() ~ "continuous2"
),
statistic = list(
all_continuous() ~ c(
"{mean}",
"{median} ({p25}, {p75})",
"{min}, {max}"
)
),
digits = list(
all_continuous() ~ 2
)
)