tabmulti {tab} | R Documentation |
Create Table Comparing Characteristics Across Levels of a Categorical Variable
Description
Creates a table comparing multiple characteristics (e.g. median age, mean
BMI, and race/ethnicity distribution) across levels of x
.
Usage
tabmulti(
formula = NULL,
data,
xvarname = NULL,
yvarnames = NULL,
ymeasures = NULL,
columns = c("xgroups", "p"),
listwise.deletion = FALSE,
sep.char = ", ",
xlevels = NULL,
yvarlabels = NULL,
ylevels = NULL,
quantiles = NULL,
quantile.vals = FALSE,
decimals = NULL,
formatp.list = NULL,
n.headings = FALSE,
tabmeans.list = NULL,
tabmedians.list = NULL,
tabfreq.list = NULL,
kable = TRUE
)
Arguments
formula |
Formula, e.g. |
data |
Data frame containing variables named in |
xvarname |
Character string with name of column variable. Should be one
of |
yvarnames |
Character vector with names of row variables. Each element
should be one of |
ymeasures |
Character vector specifying whether each |
columns |
Character vector specifying what columns to include. Choices
for each element are |
listwise.deletion |
Logical value for whether observations with missing
values for any |
sep.char |
Character string with separator to place between lower and
upper bound of confidence intervals. Typically |
xlevels |
Character vector with labels for the levels of |
yvarlabels |
Named list specifying labels for certain |
ylevels |
Character vector (if only 1 frequency comparison) or list of
character vectors with labels for the levels of each categorical |
quantiles |
Numeric value. If specified, function compares |
quantile.vals |
Logical value for whether labels for |
decimals |
Numeric vector specifying number of decimal places for
numbers other than p-values for each |
formatp.list |
List of arguments to pass to |
n.headings |
Logical value for whether to display group sample sizes in parentheses in column headings. |
tabmeans.list |
List of arguments to pass to |
tabmedians.list |
List of arguments to pass to |
tabfreq.list |
List of arguments to pass to |
kable |
Logical value for whether to return a
|
Value
kable
or character matrix.
Examples
# Compare age, sex, race, and BMI in control vs. treatment group
tabmulti(Age + Sex + Race + BMI ~ Group, data = tabdata)
# Same as previous, but compare medians rather than means for BMI
tabmulti(Age + Sex + Race + BMI ~ Group, data = tabdata,
ymeasures = c("mean", "freq", "freq", "median"))