cross_tabulate: Create cross table from a tibble

Description Usage Arguments Value Examples

Description

A wrapper of table() for convenient use in a dplyr pipeline: Pass the factors to tabulate as symbols or expressions like you would in mutate(). useNA and dnn are passed to table().

Usage

1
cross_tabulate(.df, ..., useNA = c("no", "ifany", "always"), dnn = NULL)

Arguments

.df

A data frame

...

Factors to tabulate by: symbolic column names / language

useNA, dnn

passed to table()

Value

Result from a call to table()

Examples

1
2
3
4
5
6
7
library(magrittr)
if (requireNamespace("survival", quietly = TRUE))
{
   survival::bladder1 %>%
      cross_tabulate(treatment, recur) %>%
      chisq.test()
}

Example output

	Pearson's Chi-squared test

data:  .
X-squared = 100.03, df = 18, p-value = 2.192e-13

Warning messages:
1: Quosure lists can't be concatenated with objects other than quosures as of rlang 0.3.0.
Please call `as.list()` on the quosure list first.
This warning is displayed once per session. 
2: In chisq.test(.) : Chi-squared approximation may be incorrect

tidytidbits documentation built on March 8, 2021, 5:07 p.m.