coerce-vector {sparsevctrs} | R Documentation |
Coerce numeric vector to sparse double
Description
Takes a numeric vector, integer or double, and turn it into a sparse double vector.
Usage
as_sparse_double(x, default = 0)
as_sparse_integer(x, default = 0L)
as_sparse_character(x, default = "")
as_sparse_logical(x, default = FALSE)
Arguments
x |
a numeric vector. |
default |
default value to use. Defaults to The values of |
Value
sparse vectors
Examples
x_dense <- c(3, 0, 2, 0, 0, 0, 4, 0, 0, 0)
x_sparse <- as_sparse_double(x_dense)
x_sparse
is_sparse_double(x_sparse)
[Package sparsevctrs version 0.1.0 Index]