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

Recycling a single value for a list column #2171

Closed
lepennec opened this issue Oct 13, 2016 · 3 comments
Closed

Recycling a single value for a list column #2171

lepennec opened this issue Oct 13, 2016 · 3 comments
Assignees
Labels
Milestone

Comments

@lepennec
Copy link

@lepennec lepennec commented Oct 13, 2016

Hi,

I'm working with list column and was trying to assign a list column with a constant value with the straightforward:

tmp <- tibble(a = c(1,2), b = list(tibble(x = 1:2), tibble(y = 1:3)))
tmp %>% mutate(c = list(1:3))

Unfortunately this does not work and I have an errpr Error: not compatible with STRSXP. The only way I have found are
tmp %>% mutate(c = rep(list(1:3), nrow(tmp)))
tmp %>% mutate(c = map(b, ~ 1:3))

Is there a more natural way to recycle a single value?

Erwan

@lepennec
Copy link
Author

@lepennec lepennec commented Oct 17, 2016

As a side note,
tmp <- tibble(a = c(1,2), b = list(tibble(x = 1:2), tibble(y = 1:3)), c = list(1:3))
works as expected

@krlmlr
Copy link
Member

@krlmlr krlmlr commented Nov 7, 2016

@hadley: We should probably make the following work as expected:

tmp %>% mutate(c = list(list(1:3)))

Anyway, the error message is not helpful.

@hadley
Copy link
Member

@hadley hadley commented Nov 7, 2016

@krlmlr agreed. This is a clear bug

@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
@krlmlr krlmlr closed this in #2543 Mar 19, 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