This analysis compares trends for ExxonMobil and Chevron using Google Trends and stock price data to explore how global events may influence energy markets.
library(gtrendsR)
gas_trends <- gtrends(c("ExxonMobil", "Chevron"),
gprop = "web",
geo = "US")
plot(gas_trends)
## Warning: `aes_string()` was deprecated in ggplot2 3.0.0.
## ℹ Please use tidy evaluation idioms with `aes()`.
## ℹ See also `vignette("ggplot2-in-packages")` for more information.
## ℹ The deprecated feature was likely used in the gtrendsR package.
## Please report the issue at <https://github.com/PMassicotte/gtrendsR/issues>.
## This warning is displayed once per session.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
## generated.
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
library(lubridate)
##
## Attaching package: 'lubridate'
## The following objects are masked from 'package:base':
##
## date, intersect, setdiff, union
getSymbols('XOM', src = 'yahoo',
from = Sys.Date() - years(4),
to = Sys.Date())
## [1] "XOM"
getSymbols('CVX', src = 'yahoo',
from = Sys.Date() - years(4),
to = Sys.Date())
## [1] "CVX"
stocks <- as.xts(data.frame(
XOM = XOM$XOM.Close,
CVX = CVX$CVX.Close
))
plot(as.zoo(stocks), screens = 1, lty = c(1,3),
col = c("red","blue"),
xlab = "Date",
ylab = "Price")
legend("top",
c("ExxonMobil (XOM)", "Chevron (CVX)"),
lty = c(1,3),
col = c("red","blue"),
cex = 0.8)
The results show fluctuations in the stock prices of ExxonMobil and Chevron over time. These changes may reflect how global economic or political events can influence oil supply, energy demand, and gas prices.