Part 29 Lab 5A: Univariate pivoting
Copy this code into your script to import the data for this lab.
library(tidyverse)
<- read_csv("https://raw.githubusercontent.com/jennybc/lotr-tidy/master/data/lotr_tidy.csv") |>
lotr rename(Species = Race)
29.1 Exercise 1: Univariate Pivoting
Consider the Lord of the Rings data:
lotr
Would you say this data is in tidy format?
Widen the data so that we see the words spoken by each species, by putting species as its own column.
<- lotr |>
(lotr_wide pivot_wider(FILL_THIS_IN = c(Film, Gender),
FILL_THIS_IN = Species,
FILL_THIS_IN = Words))
- Re-lengthen the wide LOTR data from Question 2 above.
|>
lotr_wide pivot_longer(FILL_THIS_IN = FILL_THIS_IN,
names_to = FILL_THIS_IN,
values_to = FILL_THIS_IN)