coerce_to_sparse_data_frame {sparsevctrs} | R Documentation |
Coerce sparse matrix to data frame with sparse columns
Description
Turning a sparse matrix into a data frame
Usage
coerce_to_sparse_data_frame(x)
Arguments
x |
sparse matrix. |
Details
The only requirement from the sparse matrix is that it contains column names.
Value
data.frame with sparse columns
See Also
coerce_to_sparse_tibble()
coerce_to_sparse_matrix()
Examples
set.seed(1234)
mat <- matrix(sample(0:1, 100, TRUE, c(0.9, 0.1)), nrow = 10)
colnames(mat) <- letters[1:10]
sparse_mat <- Matrix::Matrix(mat, sparse = TRUE)
sparse_mat
res <- coerce_to_sparse_data_frame(sparse_mat)
res
# All columns are sparse
vapply(res, is_sparse_vector, logical(1))
[Package sparsevctrs version 0.1.0 Index]