library(tidyr)
df <- tibble(
name = c("a", "a"),
value = c(1, 2)
)
df
#> # A tibble: 2 × 2
#> name value
#> <chr> <dbl>
#> 1 a 1
#> 2 a 2
df %>%
pivot_wider(
names_from = name,
values_from = value,
values_fn = list(value = ~.x)
)
#> Error in `$<-.data.frame`(`*tmp*`, "val", value = c(1, 2)): replacement has 2 rows, data has 1
It should be reasonably fast to call list_sizes() here and then check that they are all size 1
|
out$val <- vec_c(!!!map(out$val, values_fn)) |
It should be reasonably fast to call
list_sizes()here and then check that they are all size 1tidyr/R/pivot-wide.R
Line 361 in 51ddd56