Skip to content

Complete and expend fail on list columns #446

@garrettgman

Description

@garrettgman

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]>

Metadata

Metadata

Assignees

No one assigned

    Labels

    featurea feature request or enhancementpivoting ♻️pivot rectangular data to different "shapes"tidy-dev-day 🤓Tidyverse Developer Day rstd.io/tidy-dev-day

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions