-
Notifications
You must be signed in to change notification settings - Fork 417
Closed
Labels
featurea feature request or enhancementa feature request or enhancementpivoting ♻️pivot rectangular data to different "shapes"pivot rectangular data to different "shapes"
Description
pivot_wider
is missing the drop
option that was present in spread
which is quite useful
to fill a matrix with empty rows.
df <- tibble(x=factor(c(1,1,2), 1:3), y=c("a", "b", "b"), z=11:13)
print(df)
#> # A tibble: 3 x 3
#> x y z
#> <fct> <chr> <int>
#> 1 1 a 11
#> 2 1 b 12
#> 3 2 b 13
pivot_wider(df, names_from = y, values_from=z)
#> # A tibble: 2 x 3
#> x a b
#> <fct> <int> <int>
#> 1 1 11 12
#> 2 2 NA 13
spread(df, key=y, value=z, drop=FALSE)
#> # A tibble: 3 x 3
#> x a b
#> <fct> <int> <int>
#> 1 1 11 12
#> 2 2 NA 13
#> 3 3 NA NA
zenggyu, ccwang002, jntrcs, caldwellst, andrewgustar and 7 more
Metadata
Metadata
Assignees
Labels
featurea feature request or enhancementa feature request or enhancementpivoting ♻️pivot rectangular data to different "shapes"pivot rectangular data to different "shapes"