Creates an I-by-J frequency table comparing the distribution of y
across levels of x
.
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
)
Formula, e.g. Race ~ Sex
.
Survey design object from svydesign
.
Character vector specifying what columns to include. Choices
for each element are "n"
for total unweighted sample size, "N"
for total weighted sample size, "overall"
for overall distribution of
y
, "xgroups"
for distributions of y
for each x
group, and "p"
for Chi-square p-value.
Character string specifying what statistic to display in cells.
Choices are "n"
, "N"
, and "col.percent"
.
Character string specifying what statistic to display in
parentheses. Choices are "none"
, "n"
, "N"
,
"col.percent"
, "se"
, and "ci"
.
Character string with separator to place between lower and
upper bound of confidence intervals. Typically "-"
or ", "
.
Character vector with labels for the levels of x
, used
in column headings.
Character string with a label for the y
variable.
Character vector with labels for the levels of y
. Note
that levels of y
are listed in the order that they appear when you run
table(y, x)
.
Logical value for whether to compress binary y
variable to a single row, excluding the first level rather than showing both.
Logical value for whether to include a row displaying the
name of the y
variable.
Character string with text to put after the y
variable name, identifying what cell values and parentheses represent.
Numeric value specifying number of decimal places for numbers other than p-values.
List of arguments to pass to
svychisq
.
List of arguments to pass to formatp
.
Logical value for whether to display unweighted sample sizes in parentheses in column headings.
Logical value for whether to display weighted sample sizes in parentheses in column headings.
Logical value for whether to return a
kable
.
kable
or character matrix.
Basically tabmedians
for complex survey data. Relies heavily on
the survey package.
# NOT RUN {
# 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)
# }
Run the code above in your browser using DataLab