A Time Series Database for Official Statistics with R and PostgreSQL

Archive and manage times series data from official statistics. The 'timeseriesdb' package was designed to manage a large catalog of time series from official statistics which are typically published on a monthly, quarterly or yearly basis. Thus timeseriesdb is optimized to handle updates caused by data revision as well as elaborate, multi-lingual meta information.


{timeseriesdb}: A Time Series Database for Official Statistics

CRAN_Status_Badge CRAN_time_from_release metacran downloads license

-> GitHub Pages Documentation Site <-

{timeseriesdb} maps R time series objects to PostgreSQL database relations for permanent storage. Instead of writing time series to spreadsheet files or .RData files on disk, {timeseriesdb} uses a set of PostgreSQL relations which allows to store data alongside extensive, multi-lingual meta information in context aware fashion. {timeseriesdb} was designed with official statistics in mind: It can keep track of various versions of the same time series to handle data revisions, e.g., in the case of GDP data.

Why {timeseriesdb} ?

{timeseriesdb} ...

  • is lite weight but powerful: multi-language meta information, versioning of time series, ...
  • built entirely based on license cost free open source components.
  • tailored to the needs of Official and Economic Statistics
  • administration friendly, extendable access rights management
  • well documented, developer friendly.
  • API ready: {timeseriesdb} can easily be extended to expose data through a REST API to allow for language agnostic access to your time series.

What Does {timeseriesdb} NOT DO ?

{timeseriesdb} is not built to incrementally append new observations as fast as possible. {timeseriesdb} does not try to compete with the amazing speed of InfluxDB. It's not a server log or IoT minded time series storage.

Quick Start Guide

Make sure you followed the installation notes to make sure all components of the {timeseriesdb} were installed properly: PostgreSQL, necessary PostgreSQL extension, R as well as the {timeseriesdb} R package.

Example Use (Basic Usage)

The following examples illustrate basic use in a nutshell. The learn more about the use of {timeseriesdb}, read the vignette articles.

Store a List of R Time Series Objects to the Database

# Create DB connection. 
# In this case connect to a local db running on port 1111
# /w lame passwords -- strongly discouraged for production. 
con <- dbConnect(Postgres(),
                "dev_writer", "localhost",
                 1111, "dev_writer",
                "postgres")
tsl <- list(ts1 = ts(rnorm(100), frequency = 12,
                     start = 2002),
            ts2 = ts(rnorm(100), frequency = 12,
                     start = 2001))
db_store_ts(connection, tsl)
dbDisconnect(con)

Read Data into a list of R time Series object

con <- dbConnect(Postgres(),
                "dev_writer", "localhost",
                 1111, "dev_writer",
                "postgres")

tsl <- db_read_ts(connection, c("some_ts_id","another_ts_id"))
dbDisconnect(con)

Advanced Features

{timeseriesdb} offers a plethora of features beyond just mere storage of time series themselves:

  • store vintages (versions) of time series
  • datasets to group time series
  • store extensive, multi-lingual, versioned meta information at dataset and time series level
  • individual, user specific collections of time series similar to bookmark or playlist functionality
  • administration friendly access management with reasonable defaults (public, internal, restricted)
  • release calendar functionality to facilitate publishing

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.

install.packages("timeseriesdb")

1.0.0-1.1.2 by Matthias Bannert, 5 years ago


https://github.com/mbannert/timeseriesdb


Report a bug at https://github.com/mbannert/timeseriesdb/issues


Browse source code at https://github.com/cran/timeseriesdb


Authors: Matthias Bannert [aut, cre] , Severin Thöni [aut] , Ioan Gabriel Bucur [ctb]


Documentation:   PDF Manual  


GPL-3 license


Imports RPostgres, jsonlite, data.table, utils, xts, DBI

Suggests openxlsx, rstudioapi, dygraphs, rmarkdown, knitr


See at CRAN