## default set of statistics are available for:
# for count table:
getStats("count")
getStats("n (%)")
getStats("n")
getStats("%")
getStats("m")
getStats("%m")
getStats("m (%)")
# for continuous variable:
getStats("summary")
getStats("mean (se)")
getStats("mean (sd)")
getStats("median (range)")
getStats("median\n(range)")
getStats(c("Mean", "SE"))
## to not include statistic name in the table
getStats("median\n(range)", includeName = FALSE)
getStats(c("summary", "median\n(range)"), includeName = FALSE)
## to extract the number of decimals based on a continuous variable (see ?getMaxNDecimals)
exampleData <- data.frame(
USUBJID = 1 : 4,
WEIGHT = c(67, 78, 83, 61),
SEX = c("F", "M", "M", "F"),
stringsAsFactors = FALSE
)
getStats(type = c('median (range)', 'mean (se)'), x = exampleData$WEIGHT)
# compare with when 'x' is not specified:
getStats(type = c('median (range)', 'mean (se)'))
## custom function to format the percentages:
getStats(type = "count", formatPercentage = function(x) round(x, 2))
Run the code above in your browser using DataLab