expand_table: Expand table or matrix to data frame

View source: R/expand.R

expand_tableR Documentation

Expand table or matrix to data frame

Description

Expands a contingency table to a data frame where each observation in the table becomes a single observation in the data frame with corresponding information for each for each combination of the table dimensions.

Usage

expand_table(x)

Arguments

x

A table or matrix

Value

A data frame with the table or matrix expanded

Author(s)

Claus Ekstrom claus@rprimer.dk

Examples


expand_table(diag(3))
m <- matrix(c(2, 1, 3, 0, 0, 2), 3)
expand_table(m)
result <- expand_table(UCBAdmissions)
head(result)

# Combine into table again
xtabs(~Admit + Gender + Dept, data=result)


MESS documentation built on Aug. 21, 2023, 1:05 a.m.

Related to expand_table in MESS...