Hello, welcome to my Rmd!
I’ll be using Netflixglobal.csv data in this LBB
Let’s dig deeper into the data and name the object
netflix!
First, we can input the data
Then, using the functions head() and tail(), we will see the top data and the last data
Check dimension data:
#> [1] 1160 7
Check category in Netflix :
#> [1] "Films (English)" "Films (Non-English)" "TV (English)"
#> [4] "TV (Non-English)"
From the inspection of the data, we can conclude:
* Netflix data contain 1160 of rows and 7 of coloumn
* Category Netflix of the data : “Films (English)”,“Films
(Non-English)”,“TV (English)”,” TV (Non-English)
Check data types:
#> 'data.frame': 1160 obs. of 7 variables:
#> $ week : chr "2022-01-16" "2022-01-16" "2022-01-16" "2022-01-16" ...
#> $ category : chr "Films (English)" "Films (English)" "Films (English)" "Films (English)" ...
#> $ weekly_rank : int 1 2 3 4 5 6 7 8 9 10 ...
#> $ show_title : chr "Brazen" "Don't Look Up" "Mother/Android" "The Secret Life of Pets 2" ...
#> $ season_title : chr "" "" "" "" ...
#> $ weekly_hours_viewed : int 45340000 28390000 23170000 9390000 8790000 8710000 8710000 8470000 7860000 7000000 ...
#> $ cumulative_weeks_in_top_10: int 1 4 2 1 3 10 6 1 1 1 ...
We can see that there are some data types that do not match.
Then we can change the data type first!
#> 'data.frame': 1160 obs. of 7 variables:
#> $ week : Date, format: "2022-01-16" "2022-01-16" ...
#> $ category : Factor w/ 4 levels "Films (English)",..: 1 1 1 1 1 1 1 1 1 1 ...
#> $ weekly_rank : int 1 2 3 4 5 6 7 8 9 10 ...
#> $ show_title : chr "Brazen" "Don't Look Up" "Mother/Android" "The Secret Life of Pets 2" ...
#> $ season_title : chr "" "" "" "" ...
#> $ weekly_hours_viewed : int 45340000 28390000 23170000 9390000 8790000 8710000 8710000 8470000 7860000 7000000 ...
#> $ cumulative_weeks_in_top_10: int 1 4 2 1 3 10 6 1 1 1 ...
The data types change was successful!
We can continue to look for missing values.
Check missing value :
#> [1] FALSE
#> week category
#> 0 0
#> weekly_rank show_title
#> 0 0
#> season_title weekly_hours_viewed
#> 0 0
#> cumulative_weeks_in_top_10
#> 0
Good! No missing value.
#> [1] 2022 2022 2022 2022 2022 2022
case1 <- netflix %>%
filter(year == 2022) %>%
group_by(category) %>%
summarise(mean_viewed = mean(weekly_hours_viewed)) %>%
ungroup() %>%
arrange(desc(mean_viewed))
case1case2 <- netflix %>%
filter(category == "Films (English)" | category == "Films (Non-English)" , weekly_rank <= 3 , weekly_hours_viewed > 50000000) %>%
group_by(show_title) %>%
summarise(mean_viewed = mean(weekly_hours_viewed)) %>%
ungroup() %>%
arrange(desc(mean_viewed))
case2case3 <- netflix %>%
filter(category == "TV (English)" | category == "TV (Non-English)" , weekly_rank <= 3 , weekly_hours_viewed > 100000000) %>%
group_by(show_title) %>%
summarise(mean_viewed = mean(weekly_hours_viewed)) %>%
ungroup() %>%
arrange(desc(mean_viewed))
case3trending_channel <- netflix %>%
group_by(show_title) %>%
summarise(n_position = n()) %>%
ungroup() %>%
filter(n_position >= 10) %>%
arrange(desc(n_position))
trending_channelggplot(data = top_ten, mapping = aes(x = category, y = cumulative_weeks_in_top_10, color = category)) +
geom_boxplot()Data Visualization :
plot_topten <- ggplot(data = top_ten, mapping = aes(x = category, y = cumulative_weeks_in_top_10)) +
geom_boxplot()+
geom_jitter(aes(size = cumulative_weeks_in_top_10, color = category))+
labs(title = "Frequency of Cumulative Weeks in Top 10",
x = "Category",
y = NULL,
fill = NULL)+
scale_fill_brewer(palette = "Set2")
plot_toptenInsight : Based on data, it appears that TV (Non - English) has the highest frequency on Cumulative Weeks in Top 10.
ggplot(case1, aes(x=category, y=mean_viewed)) +
geom_col(mapping = aes(fill = category),
position = "dodge")+
labs(title = "Proportion of Mean Viewed on 2021",
subtitle = "Mean Viewed per Category",
x = "Category",
y = NULL,
fill = NULL)+
scale_fill_brewer(palette = "Set3")Insight : Based on data, TV (Non - English) has the highest average viewers in 2022.
ggplot(data = trending_channel, mapping = aes(x = n_position, y = reorder(show_title, n_position))) +
geom_segment(aes( x = 0, xend = n_position, yend = reorder(show_title, n_position)), color="black") +
geom_point(color= "indianred3", size=3,fill=alpha("orange", 0.3), alpha=0.7, shape=21, stroke=2)+
geom_text(aes(label = n_position), nudge_x = 2) +
labs(x = "Frequency", y = NULL, title = "Trending Channel Netflix")+
theme_minimal()Insight : Based on data, Money Heist is the trending channel on the frequency of show tittles.
ggplot(data = case2, aes(x = mean_viewed, y = reorder(show_title, mean_viewed)))+
geom_col(aes(fill = mean_viewed), show.legend = F)+
scale_fill_gradient(low = "rosybrown1", high = "brown4")+
geom_text(aes(label = mean_viewed), nudge_x = 5) +
labs(y = "show title", x = NULL, title = "Average Viewed of Film on Netflix")+
theme_minimal()Insight : Based on data, film with the highest average viewers in the film category is Red Notice.
ggplot(data = case3, aes(x = mean_viewed, y = reorder(show_title, mean_viewed)))+
geom_col(aes(fill = mean_viewed), show.legend = F)+
scale_fill_gradient(low = "rosybrown1", high = "brown4")+
geom_text(aes(label = mean_viewed), nudge_x = 5) +
labs(y = "show title", x = NULL, title = "Average Viewed of TV series on Netflix")+
theme_minimal()Insight : Based on data, the highest average viewers in the tv series category is Squid Game.