Skip to content

unchop() fails on data frame columns #886

@DavisVaughan

Description

@DavisVaughan
library(tidyr)

df <- tibble(x = 1:2, y = tibble(a = 1:2, b = 3:4, c = 5:6))
df
#> # A tibble: 2 x 2
#>       x   y$a    $b    $c
#>   <int> <int> <int> <int>
#> 1     1     1     3     5
#> 2     2     2     4     6

unchop(df, y)
#> Error in rep(vec_seq_along(data), n): invalid 'times' argument

# should be more like this
unpack(df, y)
#> # A tibble: 2 x 4
#>       x     a     b     c
#>   <int> <int> <int> <int>
#> 1     1     1     3     5
#> 2     2     2     4     6

This is because [[ is being used internally to do the slicing, and this isn't correct for data frame columns. It should use vec_slice2() r-lib/vctrs#626

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugan unexpected problem or unintended behaviorpivoting ♻️pivot rectangular data to different "shapes"

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions