Skip to content

unnest should handle lists #278

Closed
Closed
@hadley

Description

@hadley
library(tidyr)
library(tibble)

df <- tibble(
  x = 1:2,
  y = list(
    list("a", "b"),
    list("c", "d")
  )
)

df %>% unnest(y)
#> Error: Each column must either be a list of vectors or a list of data frames [y]

# expected:
tibble(
  x = c(1, 1, 2, 2),
  y = list("a", "b", "c", "d")
)
#> # A tibble: 4 × 2
#>       x         y
#>   <dbl>    <list>
#> 1     1 <chr [1]>
#> 2     1 <chr [1]>
#> 3     2 <chr [1]>
#> 4     2 <chr [1]>

Originally at tidyverse/purrr#265

Metadata

Metadata

Assignees

No one assigned

    Labels

    featurea feature request or enhancementrectangling 🗄️converting deeply nested lists into tidy data frames

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions