moe_wave_crosstab: weighted crosstabs with margin of error, where the x-variable...

View source: R/moeWaveCrosstab.R

moe_wave_crosstabR Documentation

weighted crosstabs with margin of error, where the x-variable identifies different survey waves

Description

moe_wave_crosstab returns a tibble containing a weighted crosstab of two variables with margin of error. Use this function when the x-variable indicates different survey waves for which weights were calculated independently.

Usage

moe_wave_crosstab(
  df,
  x,
  y,
  weight,
  remove = c(""),
  n = TRUE,
  pct_type = "row",
  format = "long",
  zscore = 1.96,
  unwt_n = FALSE
)

Arguments

df

The data source

x

The independent variable, which uniquely identifies survey waves

y

The dependent variable

weight

The weighting variable, defaults to zwave_weight

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." Column percents are not supported.

format

one of "long" or "wide"

zscore

defaults to 1.96, consistent with a 95% confidence interval

unwt_n

logical, if TRUE it adds a column with unweighted frequency values

Details

Options include row or cell percentages. The tibble can be in long or wide format. The margin of error includes the design effect of the weights, calculated separately for each survey wave.

Value

a tibble

Examples

moe_wave_crosstab(df = illinois, x = year, y = maritalstatus, weight = weight)
moe_wave_crosstab(df = illinois, x = year, y = maritalstatus, weight = weight, format = "wide")

jdjohn215/pollster documentation built on May 19, 2023, 4:34 p.m.