Description Usage Arguments Value Note See Also Examples
Converts results in a contingency table into the original raw data.
1 | expandTable(x, var.names = NULL, ...)
|
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. |
Returns a data frame of the expanded raw data from the contingency table.
This function is largely an implementation of the commands detailed in Mark Schwartz's R-help e-mail of 17Oct06 and 5Oct07.
as.data.frame.table
, type.convert
, and expandTable
in epitools.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | ## 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))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.