Learn R Programming

timeseriesdb (version 1.0.0-1.1.2)

db_dataset_trim_history: Remove Vintages from the Beginning of Dataset

Description

Removes any vintages of the given dataset that are older than a specified date.

Usage

db_dataset_trim_history(con, set_id, older_than, schema = "timeseries")

Arguments

con

RPostgres connection object.

set_id

character Name of the set to trim

older_than

Date cut off point

schema

character name of the database schema. Defaults to 'timeseries'

Details

In some cases only the last few versions of time series are of interest. This function can be used to trim off old vintages that are no longer relevant. It may be helpful to use this function with high frequency data to save disk space of versions are not needed.

See Also

Other datasets functions: db_dataset_create(), db_dataset_delete(), db_dataset_get_keys(), db_dataset_get_last_update(), db_dataset_list(), db_dataset_update_metadata(), db_ts_assign_dataset(), db_ts_get_dataset()

Examples

Run this code
# NOT RUN {
# }
# NOT RUN {
# Storing different versions of the data, use parameter valid_from
# different versions are stored with the same key
ch.kof.barometer <- kof_ts["baro_2019m11"]
names(ch.kof.barometer) <- c("ch.kof.barometer")
db_ts_store(
  con = connection,
  ch.kof.barometer,
  valid_from = "2019-12-01",
  schema = "schema"
)

ch.kof.barometer <- kof_ts["baro_2019m12"]
names(ch.kof.barometer) <- c("ch.kof.barometer")
db_ts_store(
  con = connection,
  ch.kof.barometer,
  valid_from = "2020-01-01",
  schema = "schema"
)

db_dataset_create(
  con = connection,
  set_name = "barometer",
  set_description = "KOF Barometer",
  schema = "schema"
)

db_ts_assign_dataset(
  con = connection,
  ts_keys = "ch.kof.barometer",
  set_name = "barometer",
  schema = "schema"
)

db_dataset_trim_history(
  con = connection,
  set_id = "barometer",
  older_than = "2019-12-31",
  schema = "schema"
)
# }

Run the code above in your browser using DataLab