Description Usage Arguments Value Author(s) See Also Examples
View source: R/splitAsBumpyMatrix.R
Split a vector or Vector into a BumpyMatrix based on row/column factors. This facilitates the construction of a BumpyMatrix from vector-like objects.
1 | splitAsBumpyMatrix(x, row, column, sparse = FALSE)
|
x |
A vector or Vector object, most typically a DFrame. |
row |
An object coercible into a factor, of length equal to |
column |
An object coercible into a factor, of length equal to |
sparse |
Logical scalar indicating whether a sparse representation should be used. |
A BumpyMatrix of the appropriate type,
with number of rows and columns equal to the number of levels in row
and column
respectively.
Each entry of the matrix contains all elements of x
with the corresponding indices in row
and column
.
Aaron Lun
BumpyMatrix
, if a CompressedList has already been constructed.
unsplitAsDataFrame
, which reverses this operation to recover a long-format DataFrame.
splitAsList
, which inspired this function.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | mat <- splitAsBumpyMatrix(runif(1000),
row=sample(LETTERS, 1000, replace=TRUE),
column=sample(10, 1000, replace=TRUE)
)
mat
mat[,1]
mat[1,]
# Or with a sparse representation.
mat <- splitAsBumpyMatrix(runif(10),
row=sample(LETTERS, 10, replace=TRUE),
column=sample(10, 10, replace=TRUE)
)
mat
mat[,1]
mat[1,]
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.