## Master R

Downloading and charting stock prices data become easy when using the tseries and PerformanceAnalytics R packages.

Step 2. Download the monthly adjusted closing price data on S&P500 (^GSPC) and NovaGold (NG) between Jan 2004 and Sept 2014 from Yahoo using the function get.hist.quote() from the tseries package.

Step 3. Change the class of the time index to yearmon which is appropriate for monthly data using as.yearmon() in the zoo package.

Step 4. Put both SP500 and NG price data in one data frame to make it easier for analysis.

Step 5. Calculate continuously compounded returns as difference in log prices.

Step 6. Plot returns using chart.TimeSeries() and chart.Bar() in the PerformanceAnalytics package.

Step 7. Plot cumulative returns using chart.CumReturns() in the PerformanceAnalytics package. Note we need to use simple returns instead of continuously compounded returns for this, so we first calcualte the simple returns using diff() and lag() on the price data.