« New R titles available in Chinese | Main | Get to know Cortana Analytics: Workshop and webinars »

August 27, 2015

Comments

Feed You can follow this conversation by subscribing to the comment feed for this post.

nice charts! you can do even more traditional bar charts for technical stock analysis in R. it's been awhile, but here are some examples that i was kicking around:

https://github.com/geoquant/R/tree/master/bar_charts

You have a minor typo in the code.

You use the variable 'lnkd2' instead of 'lnkd'

Love, love, love your blog!

Note that some of the packages discussed provide canned functionality both for downloading the data from Yahoo! Finance and for drawing the ggplot2 graphic.

For downloading the data, there are, of course, ready-made solutions like quantmod::getSymbols() or tseries::get.hist.quote(). If you already have the download URLs ibm_url and lnkd_url, then you can also simply use zoo::read.zoo() and merge the resulting closing prices:

library("zoo")
z <- merge(
  ibm = read.zoo(ibm_url, header = TRUE, sep = ",")$Close,
  lnkd = read.zoo(lnkd_url, header = TRUE, sep = ",")$Close
)

And the ggplot2 figure can just be drawn with the autoplot() method for zoo series:

library("ggplot2")
autoplot(z, facets = NULL)

So cool. I am a student of data and found this post very helpful. Thanks for sharing.

The comments to this entry are closed.

Search Revolutions Blog




Got comments or suggestions for the blog editor?
Email David Smith.
Follow revodavid on Twitter Follow David on Twitter: @revodavid
Get this blog via email with Blogtrottr