Untable: Untable an Aggregated Data Frame

Description Usage Arguments See Also Examples

Description

A method for recovering a data.frame out of summarized data, i.e. contingency table or aggregated data.

Usage

1
2
3
4
5
6
7
8
Untable(x, ...)

## S3 method for class 'data.frame'
Untable(x, freq = "Freq", row.names = NULL, ...)

## Default S3 method:
Untable(x, dimnames = NULL, type = NULL,
  row.names = NULL, col.names = NULL, ...)

Arguments

x

the table object as a data.frame, table, or, matrix.

freq

the column name of count values.

row.names

row names to add to data.frame if any.

dimnames

set the dimnames of object if required.

type

the type of variable. If NULL, ordered factor is returned.

col.names

column names to add to the data.frame.

...

Extra parameters ignored.

See Also

expand.grid, gl.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
gss <- data.frame(
expand.grid(sex=c("female", "male"),
party=c("dem", "indep", "rep")),
count=c(279,165,73,47,225,191))

print(gss) # aggregated data.frame

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

# Expand from a table or xtable object:
# Fisher's Tea-Tasting Experiment data
 tea <- table(poured=c("Yes", "Yes", "Yes", "No","Yes","No", "No", "No"),
             guess=c("Yes", "Yes", "Yes", "Yes", "No", "No","No","No"))

Untable(tea)

# Expand with a vector of weights
Untable(c(3,3,3), dimnames=list(c("Brazil","Colombia","Argentina")))

SciencesPo documentation built on May 29, 2017, 9:28 p.m.