tabmeans {tab} | R Documentation |
Create Table Comparing Group Means
Description
Creates a table comparing the mean of y
across levels of x
.
Usage
tabmeans(
formula = NULL,
data = NULL,
x = NULL,
y = NULL,
columns = c("xgroups", "p"),
parenth = "sd",
sep.char = ", ",
variance = "unequal",
xlevels = NULL,
yname = NULL,
text.label = NULL,
quantiles = NULL,
quantile.vals = FALSE,
decimals = NULL,
formatp.list = NULL,
n.headings = TRUE,
kable = TRUE
)
Arguments
formula |
Formula, e.g. |
data |
Data frame containing variables named in |
x |
Vector of values for the categorical |
y |
Vector of values for the continuous |
columns |
Character vector specifying what columns to include. Choices
for each element are |
parenth |
Character string specifying what statistic to display in
parentheses after the means. Choices are |
sep.char |
Character string with separator to place between lower and
upper bound of confidence intervals. Typically |
variance |
Character string specifying which version of the two-sample
t-test to use if |
xlevels |
Character vector with labels for the levels of |
yname |
Character string with a label for the |
text.label |
Character string with text to put after the |
quantiles |
Numeric value. If specified, table compares |
quantile.vals |
Logical value for whether labels for |
decimals |
Numeric value specifying number of decimal places for numbers other than p-values. |
formatp.list |
List of arguments to pass to |
n.headings |
Logical value for whether to display group sample sizes in parentheses in column headings. |
kable |
Logical value for whether to return a
|
Details
A t-test is used to compare means if x
has two levels, and a one-way
analysis of variance is used if x
has more than two levels.
Observations with missing values for x
and/or y
are dropped.
Value
kable
or character matrix.
Examples
# Compare mean BMI in control vs. treatment group in sample dataset
(meanstable1 <- tabmeans(BMI ~ Group, data = tabdata))
# Compare mean baseline systolic BP across tertiles of BMI
(meanstable2 <- tabmeans(bp.1 ~ BMI, data = tabdata,
quantiles = 3, yname = "Systolic BP"))