Skip to content

Should unnest_wider() default to some separator for unnamed entries? #1367

@hadley

Description

@hadley

I can't imagine that this behaviour is ever useful:

library(tidyr)

df <- tribble(
  ~x, ~y,
  1, c(11, 12, 13),
  2, 21
)
df |> unnest_wider(y)
#> New names:
#> New names:
#> • `` -> `...1`
#> • `` -> `...2`
#> • `` -> `...3`
#> # A tibble: 2 × 4
#>       x  ...1  ...2  ...3
#>   <dbl> <dbl> <dbl> <dbl>
#> 1     1    11    12    13
#> 2     2    21    NA    NA

Created on 2022-06-06 by the reprex package (v2.0.1)

What if it was instead:

df |> unnest_wider(y)
#> Warning: 
#> * Using unnest_wider() with column containing unnamed data
#> i Use `names_sep = "_"` to suppress this warning and control the separator.
#> # A tibble: 2 × 4
#>       x   y_1   y_2   y_3
#>   <dbl> <dbl> <dbl> <dbl>
#> 1     1    11    12    13
#> 2     2    21    NA    NA

?

Metadata

Metadata

Assignees

Labels

featurea feature request or enhancementnesting 🐦nesting, chopping, and packing

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions