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_dfr(..., .id='colname') should return empty DF with one column when input is empty list #824

Closed
meowcat opened this issue Apr 20, 2021 · 2 comments
Labels
bug an unexpected problem or unintended behavior map 🗺️ vctrs ♣️

Comments

@meowcat
Copy link

meowcat commented Apr 20, 2021

Brief description of the problem

library(tidyyverse)
map_dfr(list(), ~.x, .id = "test")

This returns a 0x0 tibble. However, I rely downstream on a column "test" existing (this is the only column that's guaranteed to exist). I would expect the result to be a 0x1 tibble with a column called "test", since the result of map_dfr with lists of different-named element + .id is a dataframe with the union of all columns plus the ID column:

list(list(a=1, b=2), list(a=1, c=3)) %>% map_dfr(~.x)
list(list(a=1, b=2), list(a=1, c=3)) %>% map_dfr(~.x, .id = "col")

Therefore, with zero columns, this should be the union of all columns (none) plus the ID column.

@hadley
Copy link
Member

hadley commented Aug 23, 2022

Root cause is probably a vctrs issue. Reprex:

purrr::map_dfr(list(), ~.x, .id = "test")
#> # A tibble: 0 × 0
vctrs::vec_rbind(.names_to = "test")
#> data frame with 0 columns and 0 rows

Created on 2022-08-23 by the reprex package (v2.0.1)

@hadley
Copy link
Member

hadley commented Aug 27, 2022

Now tracking in vctrs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug an unexpected problem or unintended behavior map 🗺️ vctrs ♣️
Projects
None yet
Development

No branches or pull requests

2 participants