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

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

Closed
jennybc opened this issue May 14, 2020 · 3 comments · Fixed by #960
Closed

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

jennybc opened this issue May 14, 2020 · 3 comments · Fixed by #960

Comments

@jennybc
Copy link
Member

jennybc commented May 14, 2020

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)

@hadley
Copy link
Member

hadley commented May 14, 2020

Interesting:

library(tidyr)

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

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

Do you have dev tidyr? Maybe I already fixed this!!

@jennybc
Copy link
Member Author

jennybc commented May 14, 2020

My issue is with unnest_auto() though.

@hadley
Copy link
Member

hadley commented May 14, 2020

Oh 😭

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants