as_sparta {sparta} | R Documentation |
As sparse table
Description
Turn an array-like object or a data.frame into a sparse representation
Usage
as_sparta(x)
## S3 method for class 'array'
as_sparta(x)
## S3 method for class 'matrix'
as_sparta(x)
## S3 method for class 'table'
as_sparta(x)
## S3 method for class 'sparta'
as_sparta(x)
## S3 method for class 'data.frame'
as_sparta(x)
Arguments
x |
array-like object or a data.frame |
Value
A sparta object
See Also
Examples
# ----------
# Example 1)
# ----------
x <- array(
c(1,0,0,2,3,4,0,0),
dim = c(2,2,2),
dimnames = list(
a = c("a1", "a2"),
b = c("b1", "b2"),
c = c("c1", "c2")
)
)
as_sparta(x)
# ----------
# Example 2)
# ----------
y <- mtcars[, c("gear", "carb")]
y[] <- lapply(y, as.character)
as_sparta(y)
[Package sparta version 0.8.4 Index]