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

Complete and expend fail on list columns #446

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

Complete and expend fail on list columns #446

garrettgman opened this issue Apr 23, 2018 · 3 comments
Labels
feature a feature request or enhancement pivoting ♻️ pivot rectangular data to different "shapes" tidy-dev-day 🤓 Tidyverse Developer Day rstd.io/tidy-dev-day

Comments

@garrettgman
Copy link
Member

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 hadley added feature a feature request or enhancement pivoting ♻️ pivot rectangular data to different "shapes" labels Jan 4, 2019
@hadley
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)

@hadley hadley added the tidy-dev-day 🤓 Tidyverse Developer Day rstd.io/tidy-dev-day label Jan 4, 2019
@SamanthaToet
Copy link
Contributor

Working on it!

SamanthaToet added a commit to SamanthaToet/tidyr that referenced this issue Jan 19, 2019
@hadley hadley closed this as completed in c7c2ce6 Jan 22, 2019
@hadley
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
Labels
feature a feature request or enhancement pivoting ♻️ pivot rectangular data to different "shapes" tidy-dev-day 🤓 Tidyverse Developer Day rstd.io/tidy-dev-day
Projects
None yet
Development

No branches or pull requests

3 participants