plot.xts with Moving Average Panel
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
(for all plot.xts posts, see http://timelyportfolio.blogspot.com/search/label/plot.xts)
As another example of all that we can do with the new plot.xts, let’s try to do a price plot with a moving average overlays. We will use the ETFs shown by Mebane Faber at http://www.mebanefaber.com/timing-model/. With the panel functionality, it is very easy to specify a panel to draw the price line and then add the calculated moving average. Notice how in all the examples, the recession block appears easily and very nicely.
From TimelyPortfolio |
Also, if you wanted to specify some funky layouts, we have that option. For this case, I do not think it makes much sense, but in the future I will demonstrate some more appropriate uses.
From TimelyPortfolio |
Or as one more example, let’s change it up just slightly.
From TimelyPortfolio |
R code in GIST (do raw for copy/paste and also install xtsExtra from r-forge):
R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.