Learn R Programming

SciencesPo (version 1.3.9)

untable: Untable

Description

Method for recreate the data.frame out of a contingency table, i.e., converts from summarized data to long.

Usage

untable(x, ...)

## S3 method for class 'data.frame': untable(x, freq = "Freq", rownames = NULL, ...)

## S3 method for class 'default': untable(x, dimnames = NULL, type = NULL, rownames = NULL, colnames = NULL, ...)

Arguments

x
The table object as a data.frame, table, or, matrix.
freq
The column with count values.
rownames
Row names to add to the data.frame.
dimnames
Set dimnames of an object if require.
type
The type of variable. If NULL, ordered factor is returned.
colnames
Column names to add to the data.frame.
...
Extra parameters.

encoding

UTF-8

Examples

Run this code
if (interactive()) {
gss <- data.frame(
expand.grid(sex=c("female", "male"),
party=c("dem", "indep", "rep")),
count=c(279,165,73,47,225,191))

print(gss)

# Then expand it:
GSS <- untable(gss, freq="count")
head(GSS)
}

Run the code above in your browser using DataLab