Skip to content

unnest_auto() struggles when data has a column named col #959

@jennybc

Description

@jennybc

Found while staring at spreadsheet cell data.

library(tidyverse)

dat <- tibble(
  row = 2:3,
  col = 2L,
  loc = c("B2", "B3"),
  blah = list(
    list(whatever = "a", foofy = "b"),
    list(whatever = "c", foofy = "d")
  )
)

# this is the result I expect from unnest_auto()
dat %>% unnest_wider(blah)
#> # A tibble: 2 x 5
#>     row   col loc   whatever foofy
#>   <int> <int> <chr> <chr>    <chr>
#> 1     2     2 B2    a        b    
#> 2     3     2 B3    c        d

# lots of noise about name repair but:
# * no actual unnesting happens
# * original `col` variable gets renamed to `...2`
dat %>% unnest_auto(blah)
#> Using `unnest_wider(blah)`; elements have 2 names in common
#> New names:
#> * `` -> ...1
#> New names:
#> * `` -> ...1
#> New names:
#> * ...1 -> ...2
#> # A tibble: 2 x 4
#>     row  ...2 loc   blah            
#>   <int> <int> <chr> <list>          
#> 1     2     2 B2    <named list [2]>
#> 2     3     2 B3    <named list [2]>

Created on 2020-05-14 by the reprex package (v0.3.0.9001)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions