cross_table: Generate and Display a Cross Tabulation Table

View source: R/table-cross_table.R

cross_tableR Documentation

Generate and Display a Cross Tabulation Table

Description

Generate and Display a Cross Tabulation Table

Usage

cross_table(
  data,
  percentage = NULL,
  layout = TRUE,
  expected = TRUE,
  layout_center = FALSE,
  header_underline = FALSE,
  digits = NULL,
  center_table = FALSE,
  style = NULL,
  ...
)

Arguments

data

A matrix or table of observed frequencies.

percentage

Which percentages to show. Options: TRUE/"all", "by_row", "by_col", "by_total", FALSE/NULL.

layout

Show layout legend box? Default TRUE.

expected

Show expected frequencies? Default TRUE.

layout_center

Center the layout box? Default FALSE.

header_underline

Shorten the underline beneath the column header? Default FALSE.

digits

Named list with keys ex, row_pct, col_pct, total_pct. Falls back to getOption("ct_digits").

center_table

Center entire table in terminal? Default FALSE.

style

Named list supplied using ct_style().

...

Reserved for future use.

Value

Invisibly returns the formatted cross-tabulation matrix.

Examples

cross_table(matrix(c(10, 20, 30, 40), nrow = 2))
cross_table(matrix(c(10, 20, 30, 40), nrow = 2), percentage = "all")


tabstats documentation built on July 8, 2026, 5:07 p.m.