Skip to content

ptype argument of unnest() doesn't work in CRAN version #1158

@DavisVaughan

Description

@DavisVaughan

Was somewhat horrified to learn that the ptype argument doesn't work as expected in unnest() here because of the preprocessing that is done on the unnest() side before handing off to unchop():

library(tidyr)

df <- tibble(
  terms = list("x", c("y", "z")),
  predictors = list("a", c("b", "c"))
)

ptype <- tibble(terms = character(), predictors = character())

unnest(
  data = df,
  cols = c(terms, predictors),
  ptype = ptype
)
#> Error: Can't convert <data.frame> to <character>.

unchop(
  data = df,
  cols = c(terms, predictors),
  ptype = ptype
)
#> # A tibble: 3 × 2
#>   terms predictors
#>   <chr> <chr>     
#> 1 x     a         
#> 2 y     b         
#> 3 z     c

This has been fixed in the dev version with the unchop/unnest() upgrades, but a test would be nice to ensure this doesn't happen again in unnest(). And since it is technically a fix we could add a bullet in NEWS.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugan unexpected problem or unintended behaviornesting 🐦nesting, chopping, and packing

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions