Over a million developers have joined DZone.

Time Series Data in R

DZone 's Guide to

Time Series Data in R

· Java Zone ·
Free Resource

There is no short­age of time series data avail­able on the web for use in stu­dent projects, or self-​​learning, or to test out new fore­cast­ing algo­rithms. It is now rel­a­tively easy to access these data sets directly in R.

M Com­pe­ti­tion data

The 1001 series from the M-​​competition and the 3003 series from the M3-​​competition are avail­able as part of the Mcomp pack­age in R.

Data­Mar­ket and Quandl

Both Data­Mar­ket and Quandl con­tain many thou­sands of time series that can be down­loaded directly into R. A search for “Aus­tralian Real GDP per capita” on both sites returned many vari­ants. The ver­sion from the Fed­eral Reserve Bank in 2010 US dol­lars was avail­able on both sites (Data­mar­ket and Quandl). These data can be down­loaded to R using the rdata­mar­ket and Quandl pack­ages respectively:

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

The two series should be iden­ti­cal. For some bizarre rea­son, the Quandl data comes in reverse time order so rev needs to be used, and then the time series attrib­utes applied. The Quandl func­tion will also gen­er­ate a warn­ing that no authen­ti­ca­tion token has been used. Unau­then­ti­cated users are lim­ited to 50 down­loads per day. See the help page for details.

The dmseries func­tion from the rdata­mar­ket pack­age is sim­pler to use. The short URL is pro­vided on the “Export” tab of the page for the data set on Data­mar­ket. The data come in zoo for­mat, but can eas­ily be con­verted to a ts object using as.ts.


For many years, I main­tained the Time Series Data Library con­sist­ing of about 800 time series includ­ing many from well-​​known text­books. These were trans­ferred to Data­Mar­ket in June 2012 and are now avail­able here.

R pack­ages

A num­ber of other R pack­ages con­tain time series data. The fol­low­ing pack­ages are listed in the Time Series Analy­sis Task View

  • Data from Makri­dakis, Wheel­wright and Hyn­d­man (1998) Fore­cast­ing: meth­ods and appli­ca­tions are pro­vided in the fma package.
  • Data from Hyn­d­man, Koehler, Ord and Sny­der (2008) Fore­cast­ing with expo­nen­tial smooth­ing are in the expsmooth package.
  • Data from Hyn­d­man and Athana­sopou­los (2013) Fore­cast­ing: prin­ci­ples and prac­tice are in the fpp package.
  • Data from Cryer and Chan (2010) Time series analy­sis with appli­ca­tions in R are in the TSA package.
  • Data from Shumway and Stof­fer (2011) Time series analy­sis and its appli­ca­tions are in the astsa package.
  • Data from Tsay (2005) Analy­sis of finan­cial time series are in the FinTS pack­age, along with some func­tions and script files required to work some of the examples.
  • TSdbi pro­vides a com­mon inter­face to time series databases.
  • fame pro­vides an inter­face for FAME time series databases
  • AER and Ecdat both con­tain many data sets (includ­ing time series data) from many econo­met­rics text books


Published at DZone with permission of

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}