Relative Content

Tag Archive for rgtsummary

How do I sort the output of tbl_custom_summary by row sum?

library(tidyverse) library(gtsummary) data <- tibble( id = c(1,2,3,4,5), report = c(“A,B”,”A”,”B,C”,”A,B,C”,”A,B,C”)) %>% mutate(b_present = ifelse(str_detect(report, “B”), “Yes”, “No”)) n_patients <- nrow(data) # number of patients, not reports custom_percent <- function(data, …) { n <- nrow(data) pct <- round(100*n/n_patients, 1) dplyr::tibble(pt_n = n, pt_pct = pct) } data %>% separate_rows(report, sep = “,”) %>% group_by(b_present, report) […]

P-value in tbl_strata

I am working with a large data set, and in the following example, I would like to indent the numerical variables (Scores, Time, and Grade), bold the levels of color (“Blue”, “Green”, etc.), provide p-values with 3 digits, and bold those p-values < 0.5. Thanks!