crosstab_3way: weighted 3-way crosstabs

View source: R/Crosstab3way.R

crosstab_3wayR Documentation

weighted 3-way crosstabs

Description

crosstab_3way returns a tibble containing a weighted crosstab of two variables by a third variable

Usage

crosstab_3way(
  df,
  x,
  y,
  z,
  weight,
  remove = c(""),
  n = TRUE,
  pct_type = "row",
  format = "wide",
  unwt_n = FALSE
)

Arguments

df

The data source

x

The independent variable

y

The dependent variable

z

The second control 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.

pct_type

Controls the kind of percentage values returned. One of "row" or "cell."

format

one of "long" or "wide"

unwt_n

logical, if TRUE a column is added containing unweighted frequency counts

Details

Options include row or cell percentages. The tibble can be in long or wide format. These tables are ideal for use with small multiples created with ggplot2::facet_wrap.

Value

a tibble

Examples

crosstab_3way(df = illinois, x = sex, y = educ6, z = maritalstatus, weight = weight)
crosstab_3way(df = illinois, x = sex, y = educ6, z = maritalstatus, weight = weight,
format = "wide")

pollster documentation built on May 31, 2023, 7:39 p.m.