A. Load Library
library(tidyr)
library(dplyr)
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
B. Load data from the CSV file
Netflix_tbl <- read.csv("/cloud/project/Homework2_Netflix/Files/Netflix.csv")
C. Additional Task
Find the six actors with the most appearances in TV shows
top_actors <- netflix_actors %>%
group_by(actor) %>%
summarise(Appearances = n()) %>%
arrange(desc(Appearances)) %>%
head(6)
top_actors
## # A tibble: 6 × 2
## actor Appearances
## <chr> <int>
## 1 Takahiro Sakurai 18
## 2 Yuki Kaji 16
## 3 Daisuke Ono 14
## 4 David Attenborough 14
## 5 Ashleigh Ball 12
## 6 Hiroshi Kamiya 12
1. How many movies and TV shows uploaded by Netflix since 2020?
total_videos_since_2020 <- Netflix_tbl %>%
filter(release_year >= 2020) %>%
nrow()
total_videos_since_2020
## [1] 25
2. ’ Friends’ is this a TV Show or movie ?
friends_type <- Netflix_tbl %>%
filter(title == 'Friends') %>%
select(type)
friends_type
## type
## 1 TV Show
3. Brad Anderson is Movie director or TV Show director?
director_type <- Netflix_tbl %>%
filter(director == 'Brad Anderson') %>%
select(type)
director_type
## type
## 1 Movie
## 2 Movie
4. In which year did Netflix become popular?
popular_year <- Netflix_tbl %>%
group_by(release_year) %>%
summarise(TotalVideos = n()) %>%
arrange(desc(TotalVideos)) %>%
head(1)
popular_year
## # A tibble: 1 × 2
## release_year TotalVideos
## <int> <int>
## 1 2018 1063
5. How many videos were uploaded by Netflix in 2010, 2017, or
2015?
amt_videos_uploaded <- Netflix_tbl %>%
filter(release_year %in% c(2010, 2017, 2015)) %>%
group_by(release_year) %>%
summarise(TotalVideos = n())
amt_videos_uploaded
## # A tibble: 3 × 2
## release_year TotalVideos
## <int> <int>
## 1 2010 149
## 2 2015 517
## 3 2017 959
6. How many TvShow were upload by Netflix in 2010 or in 2013?
tv_shows_2010_2013 <- Netflix_tbl %>%
filter(release_year %in% c(2010, 2013), type == 'TV Show') %>%
nrow()
tv_shows_2010_2013
## [1] 98
7. What are the top3 country which mostly used for shooting movie or
TvShow?
top_3_countries <- Netflix_tbl %>%
filter(!is.na(country) & country != "") %>%
group_by(country) %>%
summarise(TotalVideos = n()) %>%
arrange(desc(TotalVideos)) %>%
head(3)
top_3_countries
## # A tibble: 3 × 2
## country TotalVideos
## <chr> <int>
## 1 United States 2032
## 2 India 777
## 3 United Kingdom 348
8. Netflix mostly upload old movies or New Movies?
upload_pattern <- ifelse(Netflix_tbl$release_year > 2016, "New", "Old")
# Assuming category new is for movies released after 2016
upload_counts <- table(upload_pattern)
upload_counts
## upload_pattern
## New Old
## 2890 3344