I often find myself changing the labels of a gtsummary object post function:
table1<- trial%>%
gtsummary()
I change the labels of the gtsummary object “manually”
table1[["table_body"]][["label"]] <- table1[["table_body"]][["label"]]%>%str_to_title()
I have made this part into a function:
clean_tbl_labels <- function(tbl){
tbl[["table_body"]][["label"]]<- tbl[["table_body"]][["label"]] %>%gsub("_", " ", .) %>% str_to_title()
return(tbl)
}
but there must be an easier way to do this?
I am thinking of something along the lines:
table1<- trial%>%
gtsummary(.,
label = list(.x ~ str_to_title())