table1 {tableeasy} | R Documentation |
Table 1
Description
Create an object summarizing all baseline variables ( both continuous and categorical ). The function is improved on the basis of tableone::CreateTableOne to become more convenient to use.
Usage
table1(
var,
strata,
data,
normal = c("age", "bmi", "sbp", "dbp"),
catDigits = 1,
contDigits = 1,
pDigits = 3,
showAllLevels = FALSE
)
Arguments
var |
A vector of strings. Variables to be summarized given as a character vector. |
strata |
A vector of strings. Stratifying (grouping) variable name(s) given as a character vector. |
data |
A data frame in which these variables exist. |
normal |
A vector of strings, default |
catDigits |
An integer, Number of decimal places in the table of continuous variables. |
contDigits |
An integer, Number of decimal places in the table of categorical variables. |
pDigits |
An integer, Number of decimal places in the table of p values. |
showAllLevels |
Bool, default |
Value
An object describing baseline characteristics.
Examples
## Load Mayo Clinic Primary Biliary Cirrhosis Data
library(survival)
library(tableeasy)
data(pbc)
## Check variables
head(pbc)
## Make categorical variables factors
varsToFactor <- c('status','trt','ascites','hepato','spiders','edema','stage','sex')
pbc[varsToFactor] <- lapply(pbc[varsToFactor], factor)
##Table 1
table1(var=c('age','albumin','alk.phos','ast','edema','ascites','bili','chol'),strata='trt',pbc)