on the way to R6 class + remove truncated days (simplifications)
[talweg.git] / pkg / R / Data.R
CommitLineData
f17665c7 1#' Data
3d69ff21 2#'
f17665c7 3#' Data encapsulation
3d69ff21
BA
4#'
5#' @field data List of
6#' \itemize{
7#' \item time: vector of times
8#' \item serie: centered series
9#' \item level: corresponding levels
f17665c7 10#' \item exo: exogenous variables
3d69ff21 11#' \item exo_hat: predicted exogenous variables
3d69ff21
BA
12#' }
13#'
f17665c7
BA
14#' @docType class
15#' @importFrom R6 R6Class
16#'
17#' @export
18Data = R6Class("Data",
19 public = list(
20 data = "list",
3d69ff21
BA
21 initialize = function(...)
22 {
23 "Initialize empty Data object"
f17665c7 24#TODO: continue from here
3d69ff21
BA
25 callSuper(...)
26 },
27 getSize = function()
28 {
e030a6e3
BA
29 "Number of series in the dataset"
30
3d69ff21
BA
31 length(data)
32 },
e030a6e3
BA
33 getStdHorizon = function()
34 {
35 "'Standard' horizon, from t+1 to midnight"
36
f17665c7 37 24 - as.POSIXlt( data[[1]]$time[1] )$hour + 1
e030a6e3 38 },
dea7ff86 39 append = function(new_time, new_serie, new_level, new_exo_hat, new_exo)
3d69ff21 40 {
dea7ff86 41 "Acquire a new vector of lists (time, serie, level, exo_hat, exo)"
3d69ff21
BA
42
43 data[[length(data)+1]] <<- list("time"=new_time,"serie"=new_serie,"level"=new_level,
dea7ff86 44 "exo_hat"=new_exo_hat,"exo"=new_exo)
3d69ff21
BA
45 },
46 getTime = function(index)
47 {
1e20780e 48 "Time values at specified index"
3d69ff21 49
09cf9c19 50 index = dateIndexToInteger(index, .self)
3d69ff21
BA
51 data[[index]]$time
52 },
53 getCenteredSerie = function(index)
54 {
1e20780e 55 "Serie values (centered) at specified index"
3d69ff21 56
09cf9c19 57 index = dateIndexToInteger(index, .self)
3d69ff21
BA
58 data[[index]]$serie
59 },
60 getLevel = function(index)
61 {
1e20780e 62 "Level of the serie at specified index"
3d69ff21 63
09cf9c19 64 index = dateIndexToInteger(index, .self)
3d69ff21
BA
65 data[[index]]$level
66 },
67 getSerie = function(index)
68 {
1e20780e 69 "Serie values (centered+level) at specified index"
3d69ff21 70
09cf9c19 71 index = dateIndexToInteger(index, .self)
3d69ff21
BA
72 data[[index]]$serie + data[[index]]$level
73 },
74 getExoHat = function(index)
75 {
1e20780e 76 "Exogeous predictions at specified index"
3d69ff21 77
09cf9c19 78 index = dateIndexToInteger(index, .self)
3d69ff21
BA
79 data[[index]]$exo_hat
80 },
1e20780e 81 getExo = function(index)
3d69ff21 82 {
1e20780e 83 "Exogenous measures at specified index"
3d69ff21 84
09cf9c19 85 index = dateIndexToInteger(index, .self)
dea7ff86 86 data[[index]]$exo
3d69ff21
BA
87 }
88 )
89)