coerce_to_sparse_matrix | R Documentation |
Turning data frame with sparse columns into sparse matrix using
Matrix::sparseMatrix()
.
coerce_to_sparse_matrix(x, call = rlang::caller_env(0))
x |
a data frame or tibble with sparse columns. |
call |
The execution environment of a currently
running function, e.g. |
No checking is currently do to x
to determine whether it contains sparse
columns or not. Thus it works with any data frame. Needless to say, creating
a sparse matrix out of a dense data frame is not ideal.
sparse matrix
coerce_to_sparse_data_frame()
coerce_to_sparse_tibble()
sparse_tbl <- lapply(1:10, function(x) sparse_double(x, x, length = 10))
names(sparse_tbl) <- letters[1:10]
sparse_tbl <- as.data.frame(sparse_tbl)
sparse_tbl
res <- coerce_to_sparse_matrix(sparse_tbl)
res
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.