tabulate_rowcol: Contigency Table: Tabulate Rows Times Columns

View source: R/tables.R

tabulate_rowcolR Documentation

Contigency Table: Tabulate Rows Times Columns

Description

Tabulates row variable times col variable. Supports tidy evaluation for row and col; see examples.

Usage

tabulate_rowcol(data, row, col, maxlevels = 30, rowsums = TRUE, colsums = TRUE)

Arguments

data

Data frame (tibble).

row

Row variable.

col

Column variable.

maxlevels

Optional. Maximum number of levels for rows and columns. If a row or column variable has more than this number of levels, for example because it is actually a continuous variable, then only a warning, not a hard error, will be shown. Defaults to 30.

rowsums

Optional. Show row sums? Defaults to TRUE.

colsums

Optional. Show column sums? Defaults to TRUE.

Value

Tibble.

Examples

data(mtcars)
mtcars %>%
  tabulate_rowcol(gear, carb)

# Swap rows and columns, turn off totals:
mtcars %>%
  tabulate_rowcol(row = carb, col = gear,
                  rowsum = FALSE, colsum = FALSE)

stopsack/khsmisc documentation built on Sept. 22, 2023, 12:26 p.m.