`summarise()` has grouped output by 'year'. You can override using the
`.groups` argument.
new_filter_genre
# A tibble: 36 × 3
# Groups: year [10]
year genres avg_rate
<int> <fct> <dbl>
1 1980 Comedy 3.55
2 1980 Drama 3.83
3 1980 Horror 3.89
4 1980 Thriller 3
5 1981 Comedy 3.6
6 1981 Drama 3.68
7 1981 Horror 2.77
8 1981 Thriller 3.17
9 1982 Comedy 3.41
10 1982 Drama 3.85
# ℹ 26 more rows
Then, I plotted the ratings of the 4 genres as the years go by
plot1 <- new_filter_genre |>ggplot(aes(color = genres, x = year, y = avg_rate, group = genres)) +geom_line(position ="identity") +scale_color_brewer(palette ="Set2") +geom_point(position ="identity") +labs(title ="Ratings of Popular Genres in the 1980s",x ="Year", y ="Rating", color ="Genres") +theme_minimal(base_family ="serif") +scale_x_continuous(breaks =~axisTicks(., log =FALSE)) +# I used https://stackoverflow.com/questions/70596445/how-to-avoid-default-conversion-of-year-into-decimals-when-plotting to help me fix the decimal points in the years.ylim(1,5)plot1
I loaded highcharter to try an interactive visualization
library(highcharter)
Registered S3 method overwritten by 'quantmod':
method from
as.zoo.data.frame zoo
Attaching package: 'highcharter'
The following object is masked from 'package:dslabs':
stars
I plotted the same visual from before but now it is interactive (This is my final visualization, please grade this one)
highchart() |>hc_add_series(data = new_filter_genre,type ="line",hcaes(x = year,y = avg_rate, group = genres)) |>hc_colors(brewer.pal(4, "Dark2")) |>hc_xAxis(title =list(text="Year")) |>hc_yAxis(title =list(text="Average Rating"), min =1, max =5) |># I used https://stackoverflow.com/questions/57468457/how-can-i-set-the-yaxis-limits-within-highchart-plot to help be set a limit to y-axishc_plotOptions(series =list(marker =list(symbol ="circle"))) |>hc_legend(align ="left", verticalAlign ="top") |>hc_title(text ="Average Ratings of Movies in the 80s by Genre") |>hc_add_theme(hc_theme_538()) #I used https://stackoverflow.com/questions/56550264/how-do-i-access-highcharts-themes-modify-and-create-new-themes to help me change the theme and https://jkunst.com/highcharter/articles/themes.html#themes to look at the different theme options and adding a title.
Essay
I created my graph by choosing a data set from DS Labs and picked the movie ratings. The data set is a list of movies in all genres from 1916 to 2016 and their ratings (I’m assuming out of 5 stars). I chose the 80s just because I wanted to see the difference in genre ratings at that time. It would be cool to compare that with another decade but I decided to stick with only one graph. I chose an interactive graph to challenge myself and I’m glad it worked out. The only issue there is that since some are close together it may be hard to switch between them. First, I filtered just the 80s and the four singular genres (because some were multiple). Then I found the average of the ratings for each genre in each year so the line was smooth. Finally, I graphed it. I found the odd dip in ratings of horror in 1984 so I wonder what movies came out that people disliked. I also found that at the end of the 1980s thrillers had a sharp increase in average ratings so I would like to see which movies changed that. Drama and comedies seemed to be stable the whole time. Also, none of the data for these genres had an average rating over 4 so I wonder why that is. Overall, it seems like horror and thriller had the most drastic changes and completely switched places at the end of the 1980s.