Site icon R-bloggers

Time series data in R

[This article was first published on Hyndsight » R, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

There is no shortage of time series data available on the web for use in student projects, or self-learning, or to test out new forecasting algorithms. It is now relatively easy to access these data sets directly in R.

M Competition data

The 1001 series from the M-competition and the 3003 series from the M3-competition are available as part of the Mcomp package in R.

DataMarket and Quandl

Both DataMarket and Quandl contain many thousands of time series that can be downloaded directly into R. A search for “Australian Real GDP per capita” on both sites returned many variants. The version from the Federal Reserve Bank in 2010 US dollars was available on both sites (Datamarket and Quandl). These data can be downloaded to R using the rdatamarket and Quandl packages respectively:

library(rdatamarket)
library(Quandl)
ausgdp <- as.ts(dmseries("http://data.is/1jDQwpr")[,1])
ausgdp2 <- ts(rev(Quandl("FRED/AUSRGDPC", type="ts")), end=2011)

The two series should be identical. For some bizarre reason, the Quandl data comes in reverse time order so rev needs to be used, and then the time series attributes applied. The Quandl function will also generate a warning that no authentication token has been used. Unauthenticated users are limited to 50 downloads per day. See the help page for details.

The dmseries function from the rdatamarket package is simpler to use. The short URL is provided on the “Export” tab of the page for the data set on Datamarket. The data come in zoo format, but can easily be converted to a ts object using as.ts.

TSDL

For many years, I maintained the Time Series Data Library consisting of about 800 time series including many from well-known textbooks. These were transferred to DataMarket in June 2012 and are now available here.

R packages

A number of other R packages contain time series data. The following packages are listed in the Time Series Analysis Task View

To leave a comment for the author, please follow the link and comment on their blog: Hyndsight » R.

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.