Open
Description
Taken from: #997 (comment)
library(dplyr)
library(tidyr)
# no hoist column is returned at all
mtcars %>%
group_nest(cyl) %>% # this gives us a list-of `data` col
slice(0) %>%
hoist(data, "mpg")
# A tibble: 0 x 2
# ... with 1 variable: cyl <dbl>
It ideally should instead return:
mtcars %>%
group_nest(cyl) %>%
slice(0) %>%
hoist(data, "mpg")
# A tibble: 0 x 2
# ... with 2 variables: cyl <dbl>, mpg <dbl>
This currently doesn't work for two reasons:
- This double
map()
should take into account the fact thatx
might be a list-of col, in which case applying the plucker to each list element could always result in the same type of plucked result. If the list elements are list-ofs or data.frames, then I think every plucked result should always have the type ofpluck(<ptype>, ...)
, but this isn't fully thought through.Lines 197 to 201 in 511fc0f
- Even if we fix the above point,
hoist()
isn't type stable due topurrr::pluck()
behavior with empty elements #1203, would forcepluck(<ptype>, ...)
to always returnNULL
, which makes fixing the above point useless right now