4/24/2017

Synopsis:

This was inspired by "Time series charts by the Economist in R using Plotly" published on R-bloggers on July 11, 2016 by Riddhiman. I have modified the code to overlay time series plot for Dow Jones Industrial Average (in 1000s) during the same period.

Current Date

options("getSymbols.warning4.0"=FALSE)
mydate <- as.character(format(Sys.Date(), "%B %d, %Y"))
par(mar = c(0,0,0,0))
plot(c(0, 1), c(0, 1), ann = F, bty = 'n', type = 'n', xaxt = 'n', yaxt = 'n')
text(x = -0.05, y = 0.4, paste("Current Date: ", mydate), cex = 2.5, col = "black", family="serif", font=2, adj=0)

Get Dow Jones market data

getSymbols('^DJI',src='yahoo', from='2004-01-01')
## [1] "DJI"
dji.zoo <- aggregate(DJI, as.yearmon, mean)
trends.zoo <- merge(trends.zoo, dji.zoo, fill=0)
##       Date From.US From.Britain DJI.Close
## 1 Jan 2004    2.25        12.25  10.54005
## 2 Feb 2004    3.00        18.50  10.60150
## 3 Mar 2004    4.25        18.50  10.32373
## 4 Apr 2004    3.25        25.75  10.41840
## 5 May 2004    2.60        15.20  10.08381
## 6 Jun 2004    3.75        14.75  10.36490

Plot