
Last chance! 50% off unlimited learning
Sale ends in
print.ContTable
and
summary.ContTable
.CreateContTable(vars, strata, data, funcNames = c("n", "miss", "p.miss",
"mean", "sd", "median", "p25", "p75", "min", "max", "skew", "kurt"),
funcAdditional, test = TRUE, testNormal = oneway.test,
argsNormal = list(var.equal = TRUE), testNonNormal = kruskal.test,
argsNonNormal = list(NULL))
list(sum = sum)
.oneway.test
. This is equivalent of the
t-test when there are only two groups.testNormal
. The default is
list(var.equal = TRUE)
, which makes it the
ordinary ANOVA that assumes equal variance across
groups.kruskal.test
(Kruskal-Wallis rank sum test). This is equivalent of the
wilcox.test (Man-Whitney U test) when there are only two
groups.testNonNormal
. The
default is list(NULL)
, which is just a
placeholder.CreateContTable
,
print.ContTable
,
summary.ContTable
,
CreateCatTable
, print.CatTable
,
summary.CatTable
,
CreateTableOne
, print.TableOne
,
summary.TableOne
## Load
library(tableone)
## Load Mayo Clinic Primary Biliary Cirrhosis Data
library(survival)
data(pbc)
## Check variables
head(pbc)
## Create an overall table for continuous variables
contVars <- c("time","age","bili","chol","albumin","copper",
"alk.phos","ast","trig","platelet","protime")
contTableOverall <- CreateContTable(vars = contVars, data = pbc)
## Simply typing the object name will invoke the print.ContTable method,
## which will show the sample size, means and standard deviations.
contTableOverall
## To further examine the variables, use the summary.ContTable method,
## which will show more details.
summary(contTableOverall)
## c("age","chol","copper","alk.phos","trig","protime") appear highly skewed.
## Specify them in the nonnormal argument, and the display changes to the median,
## and the [25th, 75th] percentile.
nonNormalVars <- c("age","chol","copper","alk.phos","trig","protime")
print(contTableOverall, nonnormal = nonNormalVars)
## To show median [min,max] for nonnormal variables, use minMax = TRUE
print(contTableOverall, nonnormal = nonNormalVars, minMax = TRUE)
## The table can be stratified by one or more variables
contTableBySexTrt <- CreateContTable(vars = contVars,
strata = c("sex","trt"), data = pbc)
## print now includes p-values which are by default calculated by oneway.test (t-test
## equivalent in the two group case). It is formatted at the decimal place specified
## by the pDigits argument (3 by default). It does <0.001 for you.
contTableBySexTrt
## The nonnormal argument toggles the p-values to the nonparametric result from
## kruskal.test (wilcox.test equivalent for the two group case).
print(contTableBySexTrt, nonnormal = nonNormalVars)
## summary now includes both types of p-values
summary(contTableBySexTrt)
## If your work flow includes copying to Excel and Word when writing manuscripts,
## you may benefit from the quote argument. This will quote everything so that
## Excel does not mess up the cells.
print(contTableBySexTrt, nonnormal = nonNormalVars, quote = TRUE)
## If you want to center-align values in Word, use noSpaces option.
print(contTableBySexTrt, nonnormal = nonNormalVars, quote = TRUE, noSpaces = TRUE)
Run the code above in your browser using DataLab