-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTv_shows_gtrends.Rmd
48 lines (38 loc) · 1.71 KB
/
Tv_shows_gtrends.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
---
title: "Google Trends Research project"
output: html_document
---
Here is some practice project about working with ggtrends.
For this mini piece, I'm just wondering if a few of my favorite shows that have the same genre/type such as "Vikings", "The Witcher", and "The Last Kingdom" spike together in popularity as people tend to look for similar shows when they are done binge-watching one. Most likely the spikes will also be visible at each shows release of a new season.
```{r message=FALSE}
library(dplyr)
library(readr)
library(magrittr)
library(gtrendsR)
library(tidyr)
library(tidyverse)
library(quantmod)
```
Time to gather the data from google trends by searching for keywords.
```{r}
trends <- gtrends(keyword=c("Vikings", "The Last Kingdom","Valhalla","Witcher"))
trends_over_time <- trends$interest_over_time
trends_over_time <- trends_over_time %>% mutate(hits = as.numeric(hits))
trends_over_time <- trends_over_time %>% replace_na(list(hits = 0))
head(trends_over_time)
tail(trends_over_time)
```
```{r}
# Plotting the trends
viz <- trends_over_time %>%
ggplot() + geom_line(aes(x = date, hits, color = keyword)) +
scale_color_discrete(name = "Show", labels = c("The Last Kingdom", "Vikings: Valhalla",
"Vikings","The Witcher")) +
labs(title = "Google Trend Data For viking/medieval related tv Shows",y = "Hits (Normalized to be between 0 and 1000", x = "Date")
viz
ggsave(filename = "gtrend_tv.png", plot = viz, width = 15, height = 10, units = "in", dpi = 300)
```
It appears that there is a popularity increase for all shows in the beginning of 2020, and 2022. It also correlates with their season release date.
```{r}
jpeg(file = "tv_show_trend.jpeg")
```