expandTable {NCStats}R Documentation

Converts results in a contingency table into the original raw data.

Description

Converts results in a contingency table into the original raw data.

Usage

expandTable(x, var.names = NULL, ...)

Arguments

x

A matrix containing the contingency table.

var.names

A vector of strings used to name the variables in the new data frame.

...

Additional arguments for the type.convert function.

Value

Returns a data frame of the expanded raw data from the contingency table.

Note

This function is largely an implementation of the commands detailed in Mark Schwartz's R-help e-mail of 17Oct06 and 5Oct07.

See Also

as.data.frame.table, type.convert, and expandTable in epitools.

Examples

## Simple example
d <- matrix(c(3,2,1,1,2,3,3,2,1),nrow=3,byrow=TRUE)
colnames(d) <- c(2,4,6)
rownames(d) <- c(1,2,3)
d
rawd <- expandTable(d,c("RowVar","ColVar"))
rawd
with(rawd,table(RowVar,ColVar))

## Example with zeroes, that is not square, and factor label names
f <- matrix(c(0,2,1,1,0,3,1,2,0,0),nrow=2,byrow=TRUE)
colnames(f) <- c("c1","c2","c3","c4","c5")
rownames(f) <- c("r1","r2")
f
rawf <- expandTable(f,c("RowVar","ColVar"))
rawf
with(rawf,table(RowVar,ColVar))


[Package NCStats version 0.4.7 Index]