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

Complete and expend fail on list columns #446

Closed
garrettgman opened this Issue Apr 23, 2018 · 3 comments

Comments

Projects
None yet
3 participants
@garrettgman
Copy link
Member

garrettgman commented Apr 23, 2018

If you have a tibble with two list columns,

data_sets <- iris %>% split(iris$Species)
formulas <- list(formula1 = Sepal.Length ~ Sepal.Width,
                 formula2 = Sepal.Length ~ Sepal.Width + Petal.Width,
                 formula3 = Sepal.Length ~ Sepal.Width + Petal.Width + Petal.Length)
(demo <- tibble(formulas = formulas, data_sets = data_sets))
## # A tibble: 3 x 2
##   formulas      data_sets            
##   <list>        <list>               
## 1 <S3: formula> <data.frame [50 × 5]>
## 2 <S3: formula> <data.frame [50 × 5]>
## 3 <S3: formula> <data.frame [50 × 5]>

You cannot use complete or expand to enumerate all of the combinations (which would be handy).

demo %>% complete(formulas, data_sets)
## Error: Each element must be either an atomic vector or a data frame.
## Problems: formulas, data_sets.

demo %>% expand(formulas, data_sets)
## Error: Each element must be either an atomic vector or a data frame.
## Problems: formulas, data_sets.

I'd want the results that expand.grid delivers

expand.grid(formulas = demo$formulas, data_sets = demo$data_sets)
as_tibble(expand.grid(formulas = formulas, data_sets = data_sets))
## # A tibble: 9 x 2
##   formulas      data_sets            
##   <list>        <list>               
## 1 <S3: formula> <data.frame [50 × 5]>
## 2 <S3: formula> <data.frame [50 × 5]>
## 3 <S3: formula> <data.frame [50 × 5]>
## 4 <S3: formula> <data.frame [50 × 5]>
## 5 <S3: formula> <data.frame [50 × 5]>
## 6 <S3: formula> <data.frame [50 × 5]>
## 7 <S3: formula> <data.frame [50 × 5]>
## 8 <S3: formula> <data.frame [50 × 5]>
## 9 <S3: formula> <data.frame [50 × 5]>
@hadley

This comment has been minimized.

Copy link
Member

hadley commented Jan 4, 2019

The root cause of this is in crossing(); I think simply adding is_bare_list() to the test should work. (This will have to eventually be reconsidered in light of vctrs, but I think we can do a quick fix for now)

@SamanthaToet

This comment has been minimized.

Copy link
Contributor

SamanthaToet commented Jan 19, 2019

Working on it!

SamanthaToet added a commit to SamanthaToet/tidyr that referenced this issue Jan 19, 2019

@hadley hadley closed this in c7c2ce6 Jan 22, 2019

@hadley

This comment has been minimized.

Copy link
Member

hadley commented Jan 22, 2019

complete() will support list columns as soon as dplyr does.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment