Learn R Programming

{timeseriesdb}: A Time Series Database for Official Statistics

-> 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

Copy Link

Version

Install

install.packages('timeseriesdb')

Monthly Downloads

302

Version

1.0.0-1.1.2

License

GPL-3

Issues

Pull Requests

Stars

Forks

Last Published

March 23rd, 2022

Functions in timeseriesdb (1.0.0-1.1.2)

as.tsmeta

Convert a List into a Metadata Object
db_access_level_delete

Delete a role in access levels table
date_to_index

Convert date-likes to time index
as.meta

Convert a List into a Metadata Object
db_access_level_list

Get All Access Levels and Their Description
db_access_level_create

Create a New Role (Access Level)
create_tsmeta

Meta in
db_access_level_set_default

Set the Default Access Level
db_collection_delete

Remove an Entire Time Series Key Collection
db_collection_get_keys

Get All Keys in a User Collection
db_collection_read_ts

Read all Time Series in a User Collection
db_dataset_get_last_update

Get the dataset last update
db_ts_delete_latest_version

Delete the Latest Vintage of a Time Series
index_to_date

Helper Function for Date Operations
setup_sql_extentions

Install PostgreSQL Schemas and Extensions
install_timeseriesdb

Install timeseriesdb
db_call_function

Helper to construct SQL function calls
db_collection_read_metadata

Read Metadata for a Collection
db_ts_find_keys

Get All keys that follow a pattern
db_dataset_get_latest_release

Get the latest Release for Given Datasets
db_collection_remove_ts

Remove Keys From a User's Collection
db_dataset_delete

Irrevocably Delete All Time Series in a Set and the Set Itself
db_collection_add_ts

Bundles Keys into an Existing Collection or Adds a New Collection
setup_sql_functions

Install timeseriesdb System Functions
db_dataset_get_keys

Get All Time Series Keys in a Given Set
db_metadata_read

Read Time Series Metadata
setup_sql_triggers

Install timeseriesdb Triggers
db_ts_trim_history

Remove Vintages from the Beginning
db_metadata_store

Store Time Series Metadata to PostgreSQL
setup_sql_tables

Install timeseriesdb System Tables
db_ts_store

Store a Time Series to the Database
db_dataset_get_next_release

Get Next Release Date for Given Datasets
db_connection_create

Create Database Connection
db_dataset_get_release

Get the latest Release for Given Datasets
db_connection_close

Close an Existing Database Connection
db_release_update

Update an Existing Release Record
db_meta_get_latest_validity

Get Latest Validity for Metadata of a Given Time Series
db_ts_read_history

Read the Entire History of a Time Series
db_grant_to_admin

GRANT all rights on a (temp) table to schema admin
db_release_list

List Data on Registered Releases
db_ts_rename

Rename Time Series by Assigning a New Key
db_get_installed_version

Get the Currently Installed Version of Timeseriesdb
db_dataset_update_metadata

Update Description and/or Metadata of a Dataset
db_ts_get_last_update

Get the times series last update
db_dataset_create

Create a New Dataset
db_dataset_read_ts

Read all Time Series in a Dataset
db_ts_read

Read Time Series From PostgreSQL into R
db_dataset_list

Get All Available Datasets and Their Description
db_collection_list

List All Available Collections for a Specific User
db_collection_get_last_update

Get the last update of a collection for a specific User
db_dataset_read_metadata

Read Dataset Meta Information
db_ts_delete

Remove Time Series from the Database
db_release_create

Create an Entry in the Release Calendar
db_release_cancel

Cancel a Scheduled Release
db_ts_assign_dataset

Assign Time Series Identifiers to a Dataset
db_dataset_trim_history

Remove Vintages from the Beginning of Dataset
db_ts_get_access_level

Find Out About the Access Level of a Vintage
setup_sql_grant_rights

Grant execute on timeseriesdb functions
setup_sql_roles

Create Roles needed for operation of timeseriesdb
has_depth_2

Test if a list has exactly depth 2
print.meta

Print Method for meta Object
db_with_tmp_read

Helper to Create and Populate a Temporary Table for Fast Reading
param_defs

Common parameters
json_to_ts

Convert JSON Representation of a Time Series into R Time Series Objects
db_ts_get_dataset

Find Datasets Given a Set
kof_ts

KOF indicators
create_meta

Create Meta Data Objects
change_access_level

Change the Access Level of a Time Series