Last active
October 11, 2019 19:28
-
-
Save anabarbosa/3dccb842c1d0a3cfd547ee90b508a19a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(ggplot2) | |
library(dplyr) | |
# Basic Analysis | |
data1 <- read_csv("path") | |
##Group season and episode | |
data1_sorted <- data1 %>% | |
arrange(season, number_in_season) %>% | |
mutate(season_episode = paste(season, number_in_season, sep = ", ")) | |
##Repeated values | |
data1_sorted %>% | |
select(season_episode) %>% | |
group_by(season_episode) %>% | |
tally() %>% | |
filter(n > 1) | |
# IMDB Rating analysis | |
rating <- data1_sorted %>% | |
select(imdb_rating) %>% | |
group_by(imdb_rating) %>% | |
tally() | |
## missing values | |
data1_sorted %>% | |
filter(is.na(imdb_rating)) %>% | |
tally() | |
## average rating | |
data1_sorted %>% | |
summarise(imdb_rating_mean = mean(imdb_rating, na.rm = TRUE)) | |
## plot IMDB rating per episode | |
episode_rating_plot <- ggplot(data1_sorted, aes(season_episode, imdb_rating, group=1)) + | |
geom_line(size=1) + | |
ggtitle("Episodes rating on IMDB") + | |
labs(y="IMDB rating", x='season, episode') | |
## average IMDB rating per season | |
season_average <- data1_sorted %>% | |
group_by(season) %>% | |
summarise(imdb_rating_average = mean(imdb_rating, na.rm = TRUE)) | |
## plot IMDB rating per season | |
season_rating_plot <- ggplot(season_average, aes(Group.1, x)) + | |
geom_line(size=1) + | |
ggtitle("Average season rating on IMDB") + | |
labs(y='IMDB rating', x='season') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment