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

names of list columns #2231

Closed
romainfrancois opened this issue Nov 6, 2016 · 6 comments
Closed

names of list columns #2231

romainfrancois opened this issue Nov 6, 2016 · 6 comments
Assignees
Labels
Milestone

Comments

@romainfrancois
Copy link
Member

@romainfrancois romainfrancois commented Nov 6, 2016

There seems to be something wrong about list columns.

Here I'm creating a list column that contains named integer vector :

> d <- data_frame( x = rep(c(1,2), c(2,4)), y = 1:6, names = letters[1:6] )
> d
# A tibble: 6 × 3
      x     y names
  <dbl> <int> <chr>
1     1     1     a
2     1     2     b
3     2     3     c
4     2     4     d
5     2     5     e
6     2     6     f
> res <- d %>% group_by(x) %>% summarise( y = list( setNames(y, names) ) )
> res$y[[1]]
c d 
1 2 
> res$y[[2]]
c d e f 
3 4 5 6 
> names( res$y[[1]])
[1] "c" "d" "e" "f"
> names( res$y[[2]])
[1] "c" "d" "e" "f"

I'd expect names( res$y[[1]]) to be c("a", "b").

@romainfrancois
Copy link
Member Author

@romainfrancois romainfrancois commented Nov 6, 2016

I suspect this is hybrid using the same data multiple times, i.e. if I force creation of a new names with paste0 it's fine:

> res <- d %>% group_by(x) %>% summarise( y = list( setNames(y, paste0("", names)) ) )
> res$y
[[1]]
a b 
1 2 

[[2]]
c d e f 
3 4 5 6 

@krlmlr
Copy link
Member

@krlmlr krlmlr commented Nov 7, 2016

Does this still happen with #2190?

@krlmlr
Copy link
Member

@krlmlr krlmlr commented Dec 8, 2016

Confirmed even with #2190 (and already in v0.5.0).

@krlmlr krlmlr added the bug label Dec 8, 2016
@krlmlr krlmlr self-assigned this Feb 10, 2017
@krlmlr krlmlr added this to the data frame 2 milestone Feb 20, 2017
@krlmlr krlmlr added this to the data frame 2 milestone Feb 20, 2017
@hadley
Copy link
Member

@hadley hadley commented Feb 21, 2017

This might be related to #1689

@krlmlr
Copy link
Member

@krlmlr krlmlr commented Mar 6, 2017

I suspect the use of shrinkable vectors causes the behavior we're seeing here. Need to investigate more.

@krlmlr
Copy link
Member

@krlmlr krlmlr commented Mar 6, 2017

It looks similar, but fixing #1689 doesn't fix this reprex yet.

@krlmlr krlmlr closed this in #2513 Mar 9, 2017
@lock lock bot locked as resolved and limited conversation to collaborators Jun 8, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants