r-lib / sparsevctrs

Sparse vector class using ALTREP
https://r-lib.github.io/sparsevctrs/
Other
4 stars 1 forks source link

Add `is_sparse_tibble()` #70

Closed EmilHvitfeldt closed 3 hours ago

EmilHvitfeldt commented 1 week ago

The gist could happen with the following R code, but it doesn't have an early return. which might slow us down on wide data.frames

is_sparse_tibble <- function(x) {
  any(vapply(x, sparsevctrs::is_sparse_vector, logical(1)))
}
simonpcouch commented 5 days ago

Just came here to file an issue about this: +1!

simonpcouch commented 5 days ago

It may also be nice to clarify in the coerce_to_sparse_tibble() (and this new function's documentation) that a user will not be able to tell from printing or class(x) that x is a sparse vs dense tibble.

EmilHvitfeldt commented 2 days ago

has been noted elsewhere. This doesn't actually test that the object is a tibble. so it should be renamed. Maybe has_sparse_elements/columns/cols()