Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

TALFs

Temporal Aggregation Level Functions


Description

Simply hand over one of these functions to the funby argument of one of the methods (e.g. aggregate) of DTSg objects which support it. The method does the rest of the work. See details for further information. Other uses are possible, but not recommended.

Usage

byFasttimeY_____(.dateTime, .helpers)

byFasttimeYQ____(.dateTime, .helpers)

byFasttimeYm____(.dateTime, .helpers)

byFasttimeYmd___(.dateTime, .helpers)

byFasttimeYmdH__(.dateTime, .helpers)

byFasttimeYmdHM_(.dateTime, .helpers)

byFasttimeYmdHMS(.dateTime, .helpers)

byFasttime______(.dateTime, .helpers)

byFasttime_Q____(.dateTime, .helpers)

byFasttime_m____(.dateTime, .helpers)

byFasttime___H__(.dateTime, .helpers)

byFasttime____M_(.dateTime, .helpers)

byFasttime_____S(.dateTime, .helpers)

byY_____(.dateTime, .helpers)

byYQ____(.dateTime, .helpers)

byYm____(.dateTime, .helpers)

byYmd___(.dateTime, .helpers)

byYmdH__(.dateTime, .helpers)

byYmdHM_(.dateTime, .helpers)

byYmdHMS(.dateTime, .helpers)

by______(.dateTime, .helpers)

by_Q____(.dateTime, .helpers)

by_m____(.dateTime, .helpers)

by___H__(.dateTime, .helpers)

by____M_(.dateTime, .helpers)

by_____S(.dateTime, .helpers)

Arguments

.dateTime

A POSIXct vector.

.helpers

A list with helper data as handed over by DTSg objects' aggregate method.

Details

There are two families of temporal aggregation level functions. The one family truncates timestamps (truncating family), the other extracts a certain part of them (extracting family). Each family comes in two flavours: one using fastPOSIXct of fasttime, the other solely relying on base R. The fasttime versions work with UTC time series or time series with an equivalent time zone only (execute grep("^(Etc/)?(UCT|UTC)$|^(Etc/)?GMT(\+|-)?0?$", OlsonNames(), ignore.case = TRUE, value = TRUE) for a full list of supported time zones) and are limited to dates between the years 1970 and 2199, but generally are faster for the extracting family of functions.

The truncating family sets timestamps to the lowest possible time of the corresponding temporal aggregation level:

  • *Y_____ truncates to year, e.g. 2000-11-11 11:11:11.1 becomes 2000-01-01 00:00:00.0

  • *YQ____ truncates to quarter, e.g. 2000-11-11 11:11:11.1 becomes 2000-10-01 00:00:00.0

  • *Ym____ truncates to month, e.g. 2000-11-11 11:11:11.1 becomes 2000-11-01 00:00:00.0

  • *Ymd___ truncates to day, e.g. 2000-11-11 11:11:11.1 becomes 2000-11-11 00:00:00.0

  • *YmdH__ truncates to hour, e.g. 2000-11-11 11:11:11.1 becomes 2000-11-11 11:00:00.0

  • *YmdHM_ truncates to minute, e.g. 2000-11-11 11:11:11.1 becomes 2000-11-11 11:11:00.0

  • *YmdHMS truncates to second, e.g. 2000-11-11 11:11:11.1 becomes 2000-11-11 11:11:11.0

By convention, the extracting family sets the year to 2199 and extracts a certain part of timestamps:

  • *______ extracts nothing, i.e. all timestamps become 2199-01-01 00:00:00.0

  • *_Q____ extracts the quarters, e.g. 2000-11-11 11:11:11.1 becomes 2199-10-01 00:00:00.0

  • *_m____ extracts the months, e.g. 2000-11-11 11:11:11.1 becomes 2199-11-01 00:00:00.0

  • *___H__ extracts the hours, e.g. 2000-11-11 11:11:11.1 becomes 2199-01-01 11:00:00.0

  • *____M_ extracts the minutes, e.g. 2000-11-11 11:11:11.1 becomes 2199-01-01 00:11:00.0

  • *_____S extracts the seconds, e.g. 2000-11-11 11:11:11.1 becomes 2199-01-01 00:00:11.0

Value

All functions return a POSIXct vector with timestamps corresponding to the function's temporal aggregation level.

See Also


DTSg

A Class for Working with Time Series Based on 'data.table' and 'R6' with Largely Optional Reference Semantics

v0.7.0
MIT + file LICENSE
Authors
Gerold Hepp [aut, cre]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.