Note: I reordered some sections

Import your data

scooby <- read_excel("../00_data/MyData.xlsx")

scrappy <- scooby %>%
    
    select(monster_type, series_name, title, run_time, imdb) %>%
    filter(monster_type %in% c("Mechanical"))

Pivoting

wide to long form

scrappy_wide <- scrappy %>%
    
    pivot_wider(names_from = imdb, 
                values_from = run_time)

scrappy_wide
## # A tibble: 15 × 13
##    monster_type series_name      title `8.2` `7.1` `7.7` `7.6` `8.7` `6.5` `7.5`
##    <chr>        <chr>            <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
##  1 Mechanical   Scooby Doo, Whe… Foul…    21    NA    NA    NA    NA    NA    NA
##  2 Mechanical   Scooby-Doo and … Robo…    NA     8    NA    NA    NA    NA    NA
##  3 Mechanical   Scooby-Doo and … Scoo…    NA     8    NA    NA    NA    NA    NA
##  4 Mechanical   A Pup Named Sco… The …    NA    NA    23    NA    NA    NA    NA
##  5 Mechanical   What's New Scoo… A Te…    NA    NA    NA    21    NA    NA    NA
##  6 Mechanical   Scooby-Doo Myst… Howl…    23    NA    NA    NA    NA    NA    NA
##  7 Mechanical   Scooby-Doo Myst… Art …    NA    NA    23    NA    NA    NA    NA
##  8 Mechanical   Scooby-Doo Myst… Hear…    NA    NA    NA    22    NA    NA    NA
##  9 Mechanical   Scooby-Doo Myst… Gate…    NA    NA    NA    NA    23    NA    NA
## 10 Mechanical   Warner Home Vid… Scoo…    NA    NA    NA    NA    NA    23    NA
## 11 Mechanical   Be Cool, Scooby… Me, …    NA    NA    NA    NA    NA    NA    22
## 12 Mechanical   Be Cool, Scooby… Junk…    NA    NA    NA    NA    NA    NA    NA
## 13 Mechanical   Be Cool, Scooby… Pizz…    NA    NA    NA    NA    NA    NA    NA
## 14 Mechanical   Scooby-Doo and … The …    NA    NA    NA    NA    NA    NA    NA
## 15 Mechanical   Scooby-Doo and … Tota…    NA    NA    NA    NA    NA    NA    NA
## # ℹ 3 more variables: `6.9` <dbl>, `6.8` <dbl>, `NA` <dbl>

long to wide form

scrappy_long <- scrappy_wide %>%
    
    pivot_longer(cols = c(`8.2`, `7.1`, `7.7`, `7.6`, `8.7`, `6.9`, `6.8`, `NA`, `6.5`, `7.5`), 
                 names_to = "imdb", 
                 values_to = "run_time")

scrappy_long
## # A tibble: 150 × 5
##    monster_type series_name                title                imdb  run_time
##    <chr>        <chr>                      <chr>                <chr>    <dbl>
##  1 Mechanical   Scooby Doo, Where Are You! Foul Play in Funland 8.2         21
##  2 Mechanical   Scooby Doo, Where Are You! Foul Play in Funland 7.1         NA
##  3 Mechanical   Scooby Doo, Where Are You! Foul Play in Funland 7.7         NA
##  4 Mechanical   Scooby Doo, Where Are You! Foul Play in Funland 7.6         NA
##  5 Mechanical   Scooby Doo, Where Are You! Foul Play in Funland 8.7         NA
##  6 Mechanical   Scooby Doo, Where Are You! Foul Play in Funland 6.9         NA
##  7 Mechanical   Scooby Doo, Where Are You! Foul Play in Funland 6.8         NA
##  8 Mechanical   Scooby Doo, Where Are You! Foul Play in Funland NA          NA
##  9 Mechanical   Scooby Doo, Where Are You! Foul Play in Funland 6.5         NA
## 10 Mechanical   Scooby Doo, Where Are You! Foul Play in Funland 7.5         NA
## # ℹ 140 more rows

Separating and Uniting

hexgirls <- scooby %>%
    
    select(title, monster_real, monster_amount, suspects_amount, series_name) %>%
    filter(monster_real %in% c("FALSE", "TRUE"),
           series_name %in% c("Warner Home Video"))

hexgirls
## # A tibble: 41 × 5
##    title                 monster_real monster_amount suspects_amount series_name
##    <chr>                 <chr>                 <dbl>           <dbl> <chr>      
##  1 Scooby-Doo on Zombie… TRUE                      7               6 Warner Hom…
##  2 Scooby-Doo and the W… TRUE                      5               4 Warner Hom…
##  3 Scooby-Doo and the A… FALSE                     3              10 Warner Hom…
##  4 Scooby-Doo and the C… TRUE                      1               4 Warner Hom…
##  5 Scooby-Doo! and the … FALSE                     4              10 Warner Hom…
##  6 Scooby-Doo! and the … FALSE                     7               9 Warner Hom…
##  7 Scooby-Doo! and the … FALSE                     2               8 Warner Hom…
##  8 Aloha, Scooby-Doo!    FALSE                     2               7 Warner Hom…
##  9 Scooby-Doo! in Where… FALSE                     3               7 Warner Hom…
## 10 Scooby-Doo! Pirates … FALSE                     4               5 Warner Hom…
## # ℹ 31 more rows

Unite two columns

hexgirls_united <- hexgirls %>%
    
    unite(col = "monstervsuspect", c(monster_amount,suspects_amount), sep = "/", )

hexgirls_united
## # A tibble: 41 × 4
##    title                                monster_real monstervsuspect series_name
##    <chr>                                <chr>        <chr>           <chr>      
##  1 Scooby-Doo on Zombie Island          TRUE         7/6             Warner Hom…
##  2 Scooby-Doo and the Witch's Ghost     TRUE         5/4             Warner Hom…
##  3 Scooby-Doo and the Alien Invaders    FALSE        3/10            Warner Hom…
##  4 Scooby-Doo and the Cyber Chase       TRUE         1/4             Warner Hom…
##  5 Scooby-Doo! and the Legend of the V… FALSE        4/10            Warner Hom…
##  6 Scooby-Doo! and the Monster of Mexi… FALSE        7/9             Warner Hom…
##  7 Scooby-Doo! and the Loch Ness Monst… FALSE        2/8             Warner Hom…
##  8 Aloha, Scooby-Doo!                   FALSE        2/7             Warner Hom…
##  9 Scooby-Doo! in Where's my Mummy?     FALSE        3/7             Warner Hom…
## 10 Scooby-Doo! Pirates Ahoy!            FALSE        4/5             Warner Hom…
## # ℹ 31 more rows

Separate a column

hexgirls_seperated <- hexgirls_united %>%
    
    separate(col = monstervsuspect, into = c("monster_amount", "suspects_amount"))

hexgirls_seperated
## # A tibble: 41 × 5
##    title                 monster_real monster_amount suspects_amount series_name
##    <chr>                 <chr>        <chr>          <chr>           <chr>      
##  1 Scooby-Doo on Zombie… TRUE         7              6               Warner Hom…
##  2 Scooby-Doo and the W… TRUE         5              4               Warner Hom…
##  3 Scooby-Doo and the A… FALSE        3              10              Warner Hom…
##  4 Scooby-Doo and the C… TRUE         1              4               Warner Hom…
##  5 Scooby-Doo! and the … FALSE        4              10              Warner Hom…
##  6 Scooby-Doo! and the … FALSE        7              9               Warner Hom…
##  7 Scooby-Doo! and the … FALSE        2              8               Warner Hom…
##  8 Aloha, Scooby-Doo!    FALSE        2              7               Warner Hom…
##  9 Scooby-Doo! in Where… FALSE        3              7               Warner Hom…
## 10 Scooby-Doo! Pirates … FALSE        4              5               Warner Hom…
## # ℹ 31 more rows