Learn R Programming

⚠️There's a newer version (1.0.0-1.1.2) of this package.Take me there.

timeseriesdb

Store and organize a large amount of low frequency time series data. The package was designed to manage a large catalog of official statistics which are typically published on monthly, quarterly or yearly basis. Thus timeseriesdb is optimized to handle a large number of lower frequency time series as opposed to a smaller amount of high frequency time series such as real time data from measuring devices. Hence timeseriesdb provides the opportunity to store extensive multi-lingual meta information. The package also provides a web GUI to explore the underlying PostgreSQL database interactively.

Installation Notes

R stable version

The stable version of the \pkg{timeseriesdb} \proglang{R} package itself can be downloaded and installed from CRAN (\proglang{R}'s official repository). The package source as well as binaries for Windows an OS X are available from CRAN. The package can be installed following \proglang{R}'s standard procedure to install packages eithe by running:

install.packages("timeseriesdb")

or using \proglang{R}'s GUI.

R developer version

The developer version of \pkg{timeseriesdb} can be obtained from github.com/mbannert/timeseriesdb. The most convenient way to install the latest developer version from inside an \proglang{R} session is to use the \pkg{devtools} package [@devtools]:

library(devtools)
install_github('mbannert/timeseriesb')

PostgreSQL

However, because \pkg{timeseriesdb} depends on \pkg{RPostgreSQL} to connect to the \proglang{PostgreSQL} database, the user needs to make sure that the \proglang{PostgreSQL}'s own library and header files are present and can be found by \pkg{RPostgreSQL}. For Windows, this library called libpq is attached to the \pkg{RPostgreSQL} package and will thus be installed with the \proglang{R} package. Hence Windows should make sure \pkg{RPostgreSQL} and should not experience further troubles.

For OS X and Linux the installation is a bit different when libpq is not present. For some Linux distributions the corresponding library can be obtained with the postgresql-devel package. Similarly on OS X, the user needs to make sure that libpq is present and can be found by \pkg{RpostgreSQL}. It is recommend to use the \pkg{homebrew} package manager running brew install postgresql. OS X and Linux users should note that previously installed versions may not contain the libraries provided by postgresql-devel package.

Database

Database setup

If you do not have a PostgreSQL database that contains a timeseries schema that suits timeseriesdb, create a schema called timeseries and run setup.sql which is located in inst/sql of your package folder. Start a psql client console from the inst/sql directory and run:

\i setup.sql

If a you are not familiar with running a PostgreSQL console, copy and paste the content of that file to the SQL window of your favorite GUI tool, e.g. PGadmin and run it.

Hstore Extension

hstore is an extension to PostgreSQL that needs to be loaded once before you can start creating tables that contain hstore data type. Simply run

CREATE EXTENSION hstore;

to do so. Also make sure to add hstore to your users search path.

CASCADE ON DELETE

By default PostgreSQL tables don't cascade on delete. That means if you delete a row in a main table you could not do so unless the corresponding row in a table referenced by foreign key is delete before. This happens for good reasons. But in the case of unlocalized meta information you want to delete unlocalized meta information when your original series is deleted. That's why the latest version of the createTable.sql uses cascade on DELETE.You can drop this constraint by dropping the foreign key and adding a new one. However, adding cascade on delete after creating the table works like:

alter table meta_data_unlocalized add constraint meta_data_unlocalized_fkey foreign key(fid) references timeseries_main (ts_key) on delete cascade

Copy Link

Version

Install

install.packages('timeseriesdb')

Monthly Downloads

270

Version

0.2.1

License

GPL-2

Maintainer

Matthias Bannert

Last Published

April 4th, 2015

Functions in timeseriesdb (0.2.1)

readMetaInformation

Read Meta Information from a Time Series Database
beginTransaction

Convenience Wrapper to SQL classics for BEGIN,COMMIT, ROLLBACK
listTsSets

List All Time Series Sets for a Particular User
searchKeys

Search Keys From Pre-Defined Or Key Based Queries
%k%

Search the Database by Keys
storeTsSet

Store a New Set of Time Series
getListDepth

Determine depth of a list
importTsList

Import A Long Format CSV File Into a List of Time Series
deactivateTsSet

Deactivate a Set of Time Series
activateTsSet

Activate a Set of Time Series
getMeta

Quickly Handle Meta Information
exportTsList

Export A List of Time Series to CSV
loadTsSet

Load a Time Series Set
storeTimeSeries

Write an R Time Series to a PostgreSQL database
createUI

Polymorphic Helpers for the Shiny Based GUI
createConObj

Conveniently Create Connection Object to PostgreSQL based timeseriesdb
resolveOverlap

Concatenate Time Series and Resolve Overlap Automatically
exploreDb

Start a GUI to Explore Data
dbIsValid,PostgreSQLConnection-method

Check Validity of a PostgreSQL connection
plot.tslist

Plot a list of Time Series Directly plot time series of mixed frequency into one plot. readTimeSeries returns a list of time series. The returned list is also of class tslist which makes it very convenient to plot timeseries, directly out of the database. This function gets automatically the right ranges for the axes to plot all values and dates in contained in the list.
storeMetaInformation

Store Meta Information to the Database
zooLikeDateconvert

Zoo like Date Conversion
addMetaInformation

Add Meta Information to R Environments
setAttrListWise

Set Attributes to Each Element of List According to a Given Vector
deleteTimeSeries

Delete Time Series from the database
searchKVP

Search Key-Value Pairs, look for existing keys in an Hstore
createChoices

Create Choices Boxes Dynamically
createHstore

Create Hstore
readTimeSeries

Read Time Series From PostgreSQL database