library(quantmod)
## Loading required package: xts
## Loading required package: zoo
##
## Attaching package: 'zoo'
## The following objects are masked from 'package:base':
##
## as.Date, as.Date.numeric
## Loading required package: TTR
## Registered S3 method overwritten by 'quantmod':
## method from
## as.zoo.data.frame zoo
getSymbols("MSFT", src="yahoo", from = "2024-10-01", to = "2025-02-01")
## [1] "MSFT"
nrow(MSFT)
## [1] 84
plot(MSFT$MSFT.Open)

library(gtrendsR)
library(dplyr)
##
## ######################### Warning from 'xts' package ##########################
## # #
## # The dplyr lag() function breaks how base R's lag() function is supposed to #
## # work, which breaks lag(my_xts). Calls to lag(my_xts) that you type or #
## # source() into this session won't work correctly. #
## # #
## # Use stats::lag() to make sure you're not using dplyr::lag(), or you can add #
## # conflictRules('dplyr', exclude = 'lag') to your .Rprofile to stop #
## # dplyr from breaking base R's lag() function. #
## # #
## # Code in packages is not affected. It's protected by R's namespace mechanism #
## # Set `options(xts.warn_dplyr_breaks_lag = FALSE)` to suppress this warning. #
## # #
## ###############################################################################
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:xts':
##
## first, last
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
library(ggplot2)
library(lubridate)
##
## Attaching package: 'lubridate'
## The following objects are masked from 'package:base':
##
## date, intersect, setdiff, union
The summary_tbl output pinpoints each service’s peak date and
average interest score.
summary_tbl <- iot %>%
group_by(keyword) %>%
summarise(
points = n(),
peak_hits = max(hits, na.rm = TRUE),
peak_date = date[which.max(hits)],
avg_hits = mean(hits, na.rm = TRUE),
.groups = "drop"
)
print(summary_tbl)
## # A tibble: 3 × 5
## keyword points peak_hits peak_date avg_hits
## <chr> <int> <int> <dttm> <dbl>
## 1 Disney Plus 91 12 2024-11-24 00:00:00 7.49
## 2 HBO Max 91 5 2023-12-31 00:00:00 3.43
## 3 Netflix 91 100 2025-07-06 00:00:00 51.1
I plotted the results with ggplot.
ggplot(iot, aes(date, hits, color = keyword)) +
geom_line(linewidth = 1) + # <-- replace size with linewidth
labs(
title = "Google Trends: Streaming Wars",
subtitle = paste0("Geo: ", geo, " | Time: ", timewin),
x = "Date", y = "Interest (0–100, scaled)"
) +
theme_minimal()

The plot shows Netflix consistently leading in search interest,
Disney Plus peaks around new movie or show releases, and HBO Max remains
lower overall but spikes during major series premieres