# default set of statistics (depending if the variable is continuous or categorical)
exampleData <- data.frame(
USUBJID = 1 : 4,
WEIGHT = c(67, 78, 83, 61),
SEX = c("F", "M", "M", "F"),
stringsAsFactors = FALSE
)
getStatsData(data = exampleData, var = c("WEIGHT", "SEX"))
# all set of statistics (depending if the variable is continuous or categorical)
getStatsData(data = exampleData, var = c("WEIGHT", "SEX"), type = "all")
# custom set of statistics for all variables
getStatsData(data = exampleData, var = c("WEIGHT", "SEX"), type = c("n", "%"))
# custom set of statistics, depending on the type of the variable
getStatsData(data = exampleData, var = c("WEIGHT", "SEX"),
type = c(cont = "median (range)", cont = "mean (se)", cat = "n (%)"),
args = list(cat = list(includeName = FALSE))
)
Run the code above in your browser using DataLab