tabfreq.svy {tab} | R Documentation |
Create Frequency Table (for Complex Survey Data)
Description
Creates an I-by-J frequency table comparing the distribution of y
across levels of x
.
Usage
tabfreq.svy(
formula,
design,
columns = c("xgroups", "p"),
cell = "col.percent",
parenth = "se",
sep.char = ", ",
xlevels = NULL,
yname = NULL,
ylevels = NULL,
compress.binary = FALSE,
yname.row = TRUE,
text.label = NULL,
decimals = 1,
svychisq.list = NULL,
formatp.list = NULL,
n.headings = FALSE,
N.headings = FALSE,
kable = TRUE
)
Arguments
formula |
Formula, e.g. |
design |
Survey design object from |
columns |
Character vector specifying what columns to include. Choices
for each element are |
cell |
Character string specifying what statistic to display in cells.
Choices are |
parenth |
Character string specifying what statistic to display in
parentheses. 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 |
ylevels |
Character vector with labels for the levels of |
compress.binary |
Logical value for whether to compress binary |
yname.row |
Logical value for whether to include a row displaying the
name of the |
text.label |
Character string with text to put after the |
decimals |
Numeric value specifying number of decimal places for numbers other than p-values. |
svychisq.list |
List of arguments to pass to
|
formatp.list |
List of arguments to pass to |
n.headings |
Logical value for whether to display unweighted sample sizes in parentheses in column headings. |
N.headings |
Logical value for whether to display weighted sample sizes in parentheses in column headings. |
kable |
Logical value for whether to return a
|
Details
Basically tabmedians
for complex survey data. Relies heavily on
the survey package.
Value
kable
or character matrix.
Examples
# Create survey design object
library("survey")
design <- svydesign(
data = tabsvydata,
ids = ~sdmvpsu,
strata = ~sdmvstra,
weights = ~wtmec2yr,
nest = TRUE
)
# Compare race distribution by sex
tabfreq.svy(Race ~ Sex, design)