untable | R Documentation |
Constructs a data frame from the count data in a contingency table, using the column and row names as classes.
untable(x, rows = "Rows", cols = "Columns", counts = FALSE)
x |
a contingency table. Missing values are not permitted. |
rows |
a character string indicating the name of the column containing the data for the rows. The default column name is "Rows." |
cols |
a character string indicating the name of the column containing the data for the columns. The default column name is "Columns." |
counts |
a logical value indicating whether there should be one row in
the result for each observation, which is the default |
A data frame containing two columns named from rows
and cols
and an
optional column named "Counts" if counts
is set to TRUE
.
The output for this function can be used for input to contingency table analysis functions that require a data frame rather than a contingency table. To convert a column from factor to ordered, use the ordered function.
ordered
## Create a small synthetic data matrix mdat <- matrix(seq(6), nrow = 2, ncol=3, dimnames = list(c("row1", "row2"), c("C.1", "C.2", "C.3"))) untable(mdat)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.