weighted_crosstab: A weighted two-way crosstab generator

Description Usage Arguments Value

View source: R/weighted_analysis.R

Description

Uses 'tabyl.tbl_svy' to create and format a two-way crosstab.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
weighted_crosstab(
  data,
  var1,
  var2,
  show_na = FALSE,
  drop_set = c("No response", "Not applicable", "Refuse"),
  output = c("n", "pct", "both"),
  totals = c("none", "as row", "as col", "both"),
  pct_denom = c("row", "col", "all"),
  round_n = 1,
  round_pct = 1
)

Arguments

data

A weighted data object of class 'tbl_svy'

var1

The variable to be tabulated, or the grouping variable

var2

(Optional) the variable to be tabulated within each 'var1' group

show_na

Whether rows/columns that are 'NA' should be included

drop_set

Which non-NA classes should be dropped

output

Whether the cells should show weighted counts, proportions, or both

totals

Whether totals should be included as a row, column, both, or neither

pct_denom

Which direction the percentages should be calculated on

round_n

How many digits to round counts to

round_pct

How many digits to round percentages to

Value

A 'data.frame' object formatted as specified


jayleetx/jayutils documentation built on Jan. 18, 2021, 3:16 p.m.