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

map_df fails on character vector as .f when .x contains null #306

Closed
yeedle opened this issue Mar 14, 2017 · 3 comments
Closed

map_df fails on character vector as .f when .x contains null #306

yeedle opened this issue Mar 14, 2017 · 3 comments

Comments

@yeedle
Copy link

yeedle commented Mar 14, 2017

Suppose I have a list with the following structure:

ls <- list(NULL, 
           list("foo"=data_frame(bar=c(1, 2, 3))), 
           list("foo"=data_frame(bar=c(4,5,6))))

using map_df to extract as a dataframe works well:

map_df(ls, ~.x[["foo"]])
## # A tibble: 6 × 1
##     bar
##   <dbl>
## 1     1
## 2     2
## 3     3
## 4     4
## 5     5
## 6     6

But if I pass in the name as an atomic character vector, I get an error:

map_df(ls, "foo")
## Error: `x` must be a vector (not a NULL)
@hadley
Copy link
Member

hadley commented Mar 21, 2017

This is fixed in the dev version. (And in the future, can you please use the reprex package to create reprexes)

@hadley hadley closed this as completed Mar 21, 2017
@hadley
Copy link
Member

hadley commented Mar 21, 2017

(Not sure whether it's the dev version of purrr or dplyr, but it definitely works for me)

@yeedle
Copy link
Author

yeedle commented Mar 22, 2017

Installed the dev version of purrr and it works for me too now. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants