crosstab returns a tibble containing a weighted crosstab of two variables
Usage
crosstab(
df,
x,
y,
weight,
remove = "",
n = TRUE,
pct_type = "row",
format = "wide",
unwt_n = FALSE
)
Value
a tibble
Arguments
df
The data source
x
The independent variable
y
The dependent variable
weight
The weighting variable
remove
An optional character vector of values to remove from final table (e.g. "refused").
This will not affect any calculations made. The vector is not case-sensitive.
n
logical, if TRUE numeric totals are included. They are included in a separate column for row and cell
percentages, but in a separate row for wide format column percentages.
pct_type
Controls the kind of percentage values returned. One of "row," "cell," or "column."
format
one of "long" or "wide"
unwt_n
logical, if TRUE a column "unweighted_n" is included containing the unweighted frequency count. It is not available when pct_type is "column"
Details
Options include row, column, or cell percentages. The tibble can be in long or wide format.