Multiple variables per column
Being a busy person, you don't want to spend too much time on Netflix, so you decide to crunch some numbers on TV show and movie durations before deciding what to watch.
You've managed to obtain a dataset named netflix_df, but its duration column has an issue. It contains strings with both a value and unit of duration ("min" or "Season").
You'll tidy this dataset so that each variable gets its own column.
As will always be the case in this course, the tidyr package has been pre-loaded for you.
Diese Übung ist Teil des Kurses
Reshaping Data with tidyr
Anleitung zur Übung
- Inspect
netflix_dfby typing its name directly in the R console and hitting Enter to see what string separates the value from the unit in thedurationcolumn. - Separate the
durationcolumn over two variables namedvalueandunit. Pass the string separating the number from the unit to thesepargument.
Interaktive Übung
Vervollständige den Beispielcode, um diese Übung erfolgreich abzuschließen.
netflix_df %>%
# Split the duration column into value and unit columns
separate(___, into = ___, sep = ___, convert = TRUE)