# Simulate some data
set.seed(123)
data <- expand.grid(sex=0:1, cohort=1:3)[rep(1:6, times=c(7, 9, 21, 22, 11, 14)),]
data$age <- runif(nrow(data), 18, 80)
data$agecat <- 1*(data$age >= 65)
data$wgt <- rnorm(nrow(data), 75, 15)
metadata <- list(
labels=list(
cohort = "Cohort",
sex = "Sex",
age = "Age",
agecat = "Age category",
wgt = "Weight"),
units=list(
age = "years",
wgt = "kg"),
categoricals=list(
cohort = list(
`1` = "Cohort A",
`2` = "Cohort B",
`3` = "Cohort C"),
sex = list(
`0` = "Female",
`1` = "Male"),
agecat = list(
`0` = "< 65",
`1` = "\U{2265} 65")))
data <- t1read(data, metadata)
table1(~ sex + age + agecat + wgt | cohort, data=data)
Run the code above in your browser using DataLab