Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sparse tibbles with constant columns stored as one value #339

Closed
vspinu opened this issue Nov 27, 2017 · 3 comments
Closed

Sparse tibbles with constant columns stored as one value #339

vspinu opened this issue Nov 27, 2017 · 3 comments

Comments

@vspinu
Copy link
Member

vspinu commented Nov 27, 2017

This is related to r-lib/vctrs#27 and #196 but I feel that a separate discussion is warranted here.

I would like to see a very simple sparse tibble where constant columns could be stored as a single value. So a tibble like this:

> tibble(a = 1:3, b = 1)
# A tibble: 3 x 2
      a     b
  <int> <dbl>
1     1     1
2     2     1
3     3     1
> 

is internally stored as:

> list(a = 1:3, b = 1)
$a
[1] 1 2 3

$b
[1] 1

This way you could store attributes along the data itself without extra space requirements and completely avoid dealing with R attributes. If such an attribute is an atomic singleton most vectorized operations should automatically propagate due to R's recycling rules and behave as if it's a proper column.

For what it's worth, I would need this for a more lightweight and more generic version of periods than what's currently implemented in lubridate.

@hadley
Copy link
Member

hadley commented Jan 8, 2018

I think this is out of scope for tibble - I think it will be a lot of work to implement (and it can't work for any C functions that don't call as.data.frame()), so it's worth starting incubating somewhere else. If the incubation is successful we could consider incorporating into tibble.

@hadley hadley closed this as completed Jan 8, 2018
@krlmlr
Copy link
Member

krlmlr commented Mar 1, 2018

How much of this would ALTREP support out of the box?

@github-actions
Copy link
Contributor

This old thread has been automatically locked. If you think you have found something related to this, please open a new issue and link to this old issue if necessary.

@github-actions github-actions bot locked and limited conversation to collaborators Dec 11, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants