install.packages("gtrendsR")
## Installing package into '/cloud/lib/x86_64-pc-linux-gnu-library/4.3'
## (as 'lib' is unspecified)
library(gtrendsR)
midterm <- gtrends(c("kevin McCarthy", "red wave"), 
                   gprop = "web", geo = c("US"))
plot(midterm)

library(gtrendsR)
stock_trends <- gtrends(c("AMAZON", "TESLA"), 
                        gprop = "web", geo = c("US"))
plot(stock_trends)

install.packages("quantmod")
## Installing package into '/cloud/lib/x86_64-pc-linux-gnu-library/4.3'
## (as 'lib' is unspecified)
install.packages("lubridate")
## Installing package into '/cloud/lib/x86_64-pc-linux-gnu-library/4.3'
## (as 'lib' is unspecified)
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('AMZN', src = 'yahoo', 
           from = Sys.Date() - years(4), to = Sys.Date())
## [1] "AMZN"
getSymbols('TSLA', src = 'yahoo', 
           from = Sys.Date() - years(4), to = Sys.Date())
## [1] "TSLA"
stocks <- as.xts(data.frame(AMZN = AMZN$"AMZN.Close",
                            TSLA = TSLA$"TSLA.Close"))
plot(as.zoo(stocks),screens = 1,lty = c(1,3),
     col = c("red","blue") ,xlab = "date",ylab = "Price")
legend("top",c("AMZN","TSLA"),
       lty = c(1,3),col = c("red","blue"),cex = 0.5)