title: “Week 8: Apply it to your data 7” author: “Luke Davies” date: “2022-10-05” output: html_document editor_options: chunk_output_type: console —
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, original_language, release_date, popularity, revenue, budget)
data_long <- data %>%
pivot_longer(cols = c(revenue, budget),
names_to = "metric",
values_to = "value")
small_long <- small_data %>%
pivot_longer(cols = c(revenue, budget),
names_to = "financial_type",
values_to = "amount")
data_sep <- data %>%
separate(col = release_date,
into = c("year", "month", "day"),
sep = "-")
small_sep <- small_data %>%
separate(col = release_date,
into = c("year", "month", "day"),
sep = "-")
small_united <- small_data %>%
unite(col = "movie_info",
original_title, original_language,
sep = " - Lang: ")
small_cleaned <- small_data %>%
drop_na(revenue)