Reshaping Data with tidyr
Jeroen Boeye
Head of Machine Learning, Faktion
separate()
separate_rows()
pivot_longer()
pivot_wider()
complete()
tibble(character = star_wars_list) %>%
unnest_wider(character) %>%
unnest_longer(films)
# A tibble: 45 x 2
name films
<chr> <chr>
1 Chewbacca Revenge of the Sith
2 Chewbacca Return of the Jedi
3 Chewbacca The Empire Strikes Back
4 Chewbacca A New Hope
5 Chewbacca The Force Awakens
6 Darth Vader Revenge of the Sith
7 Darth Vader Return of the Jedi
8 Darth Vader The Empire Strikes Back
# ... with 37 more rows
Reshaping Data with tidyr