Creating stock charts

Given R's powerful analysis and graphical capabilities, it is no surprise that R is very popular in the world of finance. In this recipe, we will learn how to plot data from the stock market using some special libraries.

Getting ready

We need the tseries and quantmod packages to run the following recipes. Let's install and load these two packages:


How to do it...

Let's first see an example using the tseries library function, get.hist.quotes(). We will compare the stock prices of three technology companies:

aapl<-get.hist.quote(instrument = "aapl", quote = c("Cl", "Vol")) goog <- get.hist.quote(instrument = "goog", quote = c("Cl", "Vol")) ...

Get R: Data Analysis and Visualization now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.