tableX: Table X (for Cross-Tabs)

View source: R/tableX.R

tableXR Documentation

Table X (for Cross-Tabs)

Description

Provides a pipe-able, clean, flexible version of table().

Usage

tableX(.data, x1, x2, type = "count", na.rm = FALSE, format_number = FALSE)

Arguments

.data

the data frame containing the variables

x1

the first bare (not quoted) variable found in .data

x2

the second bare (not quoted) variable found in .data

type

the summarized output type; can be "count", "cell_perc", "row_perc", or "col_perc"

na.rm

logical; whether missing values should be removed

format_number

default is FALSE; if TRUE, then the numbers are formatted with commas (e.g., 20,000 instead of 20000)

Examples


## Not run: 

library(furniture)
library(tidyverse)

data <- data.frame(
  x = sample(c(1,2,3,4), 100, replace=TRUE),
  y = sample(c(0,1), 100, replace=TRUE)
)

tableX(data, x, y)

data %>%
  tableX(x, y)

data %>%
  tableX(x, y, na.rm = TRUE)


## End(Not run)


TysonStanley/furniture documentation built on Feb. 15, 2024, 11:40 p.m.