Introduction

This report compares Google search interest and stock price performance for COUR (Coursera) and PSO (Pearson) over the past four years.


Load Required Packages

# Install packages (only needed once)
# install.packages("gtrendsR")
# install.packages("quantmod")
# install.packages("lubridate")

library(gtrendsR)
library(quantmod)
library(lubridate)

Yahoo Finance Stock Price Data (Last 4 Years)

# Download stock data
getSymbols('COUR', src = 'yahoo',
           from = Sys.Date() - years(4),
           to = Sys.Date())
## [1] "COUR"
getSymbols('PSO', src = 'yahoo',
           from = Sys.Date() - years(4),
           to = Sys.Date())
## [1] "PSO"
# Combine closing prices
stocks <- as.xts(data.frame(COUR = COUR$COUR.Close,
                            PSO  = PSO$PSO.Close))

# Plot stock prices
plot(as.zoo(stocks),
     screens = 1,
     lty = c(1,3),
     col = c("blue","red"),
     xlab = "Date",
     ylab = "Price")

legend("top", c("COUR","PSO"),
       lty = c(1,3),
       col = c("blue","red"),
       cex = 0.7)


Summary of Findings