Description Usage Arguments Details Value Examples
View source: R/archived/tabmedians-2020-03-28.R View source: R/tabmedians.R
Creates a table comparing the median of y
across levels of x
.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
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 values are shown in
parentheses after the medians in each cell. Choices are |
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 |
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
|
If x
has 2 levels, a Mann-Whitney U (also known as Wilcoxon
rank-sum) test is used to test whether the distribution of y
differs
in the two groups; if x
has more than 2 levels, a Kruskal-Wallis test
is used to test whether the distribution of y
differs across at
least two of the groups. Observations with missing values for x
and/or
y
are dropped.
kable
.
1 2 3 4 5 6 | # Compare median BMI in control group vs. treatment group in sample dataset
(medtable1 <- tabmedians(BMI ~ Group, data = tabdata))
# Compare median baseline systolic BP across tertiles of BMI
(medtable2 <- tabmedians(bp.1 ~ BMI, data = tabdata,
quantiles = 3, yname = "Systolic BP"))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.