-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtableone.R
More file actions
19 lines (17 loc) · 768 Bytes
/
tableone.R
File metadata and controls
19 lines (17 loc) · 768 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
pacman::p_load(tableone)
## tableone package itself
library(tableone)
## survival package for Mayo Clinic's PBC data
library(survival)
data(pbc)
# drop ID from variable list
vars <- names(pbc)[-1]
## Create Table 1 stratified by trt (can add more stratifying variables)
tableOne <- CreateTableOne(vars = vars, strata = c("trt"), data = pbc,
factorVars = c("status","edema","stage"))
## Specifying nonnormal variables will show the variables appropriately,
## and show nonparametric test p-values. Specify variables in the exact
## argument to obtain the exact test p-values.
print(tableOne, nonnormal = c("bili","chol","copper","alk.phos","trig"),
exact = c("status","stage"), smd = TRUE,
formatOptions = list(big.mark = ","))