Learn R Programming

vcdExtra (version 0.5-2)

expand.dft: Expand a frequency table to case form

Description

Converts a frequency table, given either as a table object or a data frame in frequency form to a data frame representing individual observations in the table.

Usage

expand.dft(x, var.names = NULL, freq = "Freq", ...)

expand.table(x, var.names = NULL, freq = "Freq", ...)

Arguments

x
A table object, or a data frame in frequency form containing factors and one numeric variable representing the cell frequency for that combination of factors.
var.names
A list of variable names for the factors, if you wish to override those already in the table
freq
The name of the frequency variable in the table
...
Other arguments passed down to type.convert. In particular, pay attention to na.strings (default: na.strings=NA if there are missing cells) and as.is (default: as.is=FALSE, convertin

Value

  • A data frame containing the factors in the table and as many observations as are represented by the total of the freq variable.

Details

expand.table is a synonym for expand.dft.

References

Posted on R-Help, Jan 20, 2009. http://tolstoy.newcastle.edu.au/R/e6/help/09/01/1873.html

See Also

type.convert, expandCategorical

Examples

Run this code
library(vcd)
art <- xtabs(~Treatment + Improved, data = Arthritis)
art
artdf <- expand.dft(art)
str(artdf)

Run the code above in your browser using DataLab