| mtabulate {textshape} | R Documentation |
Tabulate Frequency Counts for Multiple Vectors
Description
mtabulate - Similar to tabulate that works on
multiple vectors.
as_list - Convert a count matrix to a named list of elements. The
semantic inverse of mtabulate.
Usage
mtabulate(vects)
as_list(mat, nm = rownames(mat))
Arguments
vects |
A |
mat |
A matrix of counts. |
nm |
A character vector of names to assign to the list. |
Value
mtabulate - Returns a data.frame with
columns equal to number of unique elements and the number of rows equal to
the the original length of the vector,
list, or data.frame (length equals
number of columns in data.frame). If list of vectors is
named these will be the rownames of the dataframe.
as_list - Returns a list of elements.
Author(s)
Joran Elias and Tyler Rinker <tyler.rinker@gmail.com>.
References
https://stackoverflow.com/a/9961324/1000343
See Also
Examples
mtabulate(list(w=letters[1:10], x=letters[1:5], z=letters))
mtabulate(list(mtcars$cyl[1:10]))
## Dummy coding
mtabulate(mtcars$cyl[1:10])
mtabulate(CO2[, "Plant"])
dat <- data.frame(matrix(sample(c("A", "B"), 30, TRUE), ncol=3))
mtabulate(dat)
as_list(mtabulate(dat))
t(mtabulate(dat))
as_list(t(mtabulate(dat)))
[Package textshape version 1.7.5 Index]