data <- read_excel("myData.xlsx")
data
## # A tibble: 32,754 × 20
## id original_title original_language overview tagline release_date
## <dbl> <chr> <chr> <chr> <chr> <dttm>
## 1 760161 Orphan: First… en After e… "There… 2022-07-27 00:00:00
## 2 760741 Beast en A recen… "Fight… 2022-08-11 00:00:00
## 3 882598 Smile en After w… "Once … 2022-09-23 00:00:00
## 4 717728 Jeepers Creep… en Forced … "Evil … 2022-09-15 00:00:00
## 5 772450 Presencias es A man w… <NA> 2022-09-07 00:00:00
## 6 1014226 Sonríe es <NA> <NA> 2022-08-18 00:00:00
## 7 913290 Barbarian en In town… "Some … 2022-09-08 00:00:00
## 8 830788 The Invitation en After t… "You a… 2022-08-24 00:00:00
## 9 927341 Hunting Ava B… en Billion… "\"If … 2022-04-01 00:00:00
## 10 762504 Nope en Residen… "What’… 2022-07-20 00:00:00
## # ℹ 32,744 more rows
## # ℹ 14 more variables: title <chr>, popularity <dbl>, revenue <dbl>,
## # budget <dbl>, poster_path <chr>, vote_count <dbl>, vote_average <dbl>,
## # runtime <dbl>, status <chr>, adult <lgl>, backdrop_path <chr>,
## # genre_names <chr>, collection <chr>, collection_name <chr>
small_data <- data %>%
slice(1:5) %>%
select(id, original_title, release_date, popularity, revenue,)
small_data <- small_data %>%
mutate(original_title = factor(original_title))
Make two bar charts here - one before ordering another after
ggplot(small_data, aes(y = original_title, x = popularity)) +
geom_col() +
labs(title = "Alphabetical Order (Default)")
ggplot(small_data, aes(y = fct_reorder(original_title, popularity), x = popularity)) +
geom_col() +
labs(y = "Movie Title", title = "Reordered by Popularity")
Show examples of three functions: * fct_recode
small_data %>%
mutate(original_title = fct_recode(original_title,
"JC Reborn" = "Jeepers Creepers: Reborn"))
## # A tibble: 5 × 5
## id original_title release_date popularity revenue
## <dbl> <fct> <dttm> <dbl> <dbl>
## 1 760161 Orphan: First Kill 2022-07-27 00:00:00 5089. 9572765
## 2 760741 Beast 2022-08-11 00:00:00 2172. 56000000
## 3 882598 Smile 2022-09-23 00:00:00 1864. 45000000
## 4 717728 JC Reborn 2022-09-15 00:00:00 822. 2892594
## 5 772450 Presencias 2022-09-07 00:00:00 1021. 0
small_data %>%
mutate(original_title = fct_collapse(original_title,
"2022 Hits" = c("Beast", "Smile")))
## # A tibble: 5 × 5
## id original_title release_date popularity revenue
## <dbl> <fct> <dttm> <dbl> <dbl>
## 1 760161 Orphan: First Kill 2022-07-27 00:00:00 5089. 9572765
## 2 760741 2022 Hits 2022-08-11 00:00:00 2172. 56000000
## 3 882598 2022 Hits 2022-09-23 00:00:00 1864. 45000000
## 4 717728 Jeepers Creepers: Reborn 2022-09-15 00:00:00 822. 2892594
## 5 772450 Presencias 2022-09-07 00:00:00 1021. 0
small_data %>%
mutate(original_title = fct_lump(original_title, n = 3))
## # A tibble: 5 × 5
## id original_title release_date popularity revenue
## <dbl> <fct> <dttm> <dbl> <dbl>
## 1 760161 Orphan: First Kill 2022-07-27 00:00:00 5089. 9572765
## 2 760741 Beast 2022-08-11 00:00:00 2172. 56000000
## 3 882598 Smile 2022-09-23 00:00:00 1864. 45000000
## 4 717728 Jeepers Creepers: Reborn 2022-09-15 00:00:00 822. 2892594
## 5 772450 Presencias 2022-09-07 00:00:00 1021. 0
No need to do anything here.