Wednesday, February 20, 2013

Why I Love R

I'm updating the volatility portion of my Derivatives notes for class. I wanted to freshen a plot of the VIX index. Here is the R code to grab the complete VIX times series from Yahoo and create a pdf file:

 vix <- read.csv("http://ichart.finance.yahoo.com/table.csv?s=^VIX",  
         stringsAsFactors=FALSE)[, c(1, 7)]  
 pdf("vixplot.pdf")  
 plot(as.Date(vix[, 1]), vix[, 2], main="VIX, 1990 to Present",  
    xlab='Date', ylab='VIX', cex=0.3, type='p', ylim=c(0, 80))  
 dev.off()  

And it's a decent looking plot: