Skip to content

Instantly share code, notes, and snippets.

@lwaldron
Created July 11, 2024 11:19
Show Gist options
  • Save lwaldron/4fe64e433f80c02e107dd02319ebae34 to your computer and use it in GitHub Desktop.
Save lwaldron/4fe64e433f80c02e107dd02319ebae34 to your computer and use it in GitHub Desktop.
Summarize curatedMetagenomicData studies in one giant Epi Table 1
library(curatedMetagenomicData)
library(dplyr)
library(table1)
dat <- sampleMetadata |>
select(study_name, body_site, study_condition, age_category, age, BMI)
# labeling is optional, just to make the table nicer
label(dat$body_site) <- "Body Site"
label(dat$study_condition) <- "Study Condition"
label(dat$age_category) <- "Age Category"
label(dat$age) <- "Age"
label(dat$BMI) <- "BMI"
units(dat$age) <- "years"
table1(~ BMI + age_category + body_site + study_condition + age | study_name, data = dat,
transpose = FALSE,
dat = sampleMetadata)
@lwaldron
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment