6 #' @importFrom R6 R6Class
8 #' @field .data List of \itemize{
9 #' \item time: vector of times
10 #' \item serie: centered series
11 #' \item level: corresponding levels
12 #' \item exo: exogenous variables
13 #' \item exo_hat: predicted exogenous variables}
17 #' \item{\code{getSize()}}{
18 #' Return number of series in dataset.}
19 #' \item{\code{getStdHorizon()}}{
20 #' Return number of time steps from serie[1] until midnight}
21 #' \item{\code{append(new_time, new_centered_serie, new_level, new_exo, new_exo_hat)}}{
22 #' Acquire a new vector of lists (time, centered_serie, level, exo, exo_hat).}
23 #' \item{\code{getTime(index)}}{
24 #' Get times at specified index.}
25 #' \item{\code{getCenteredSerie(index)}}{
26 #' Get centered serie at specified index.}
27 #' \item{\code{getCenteredSeries(indices)}}{
28 #' Get centered series at specified indices (in columns).}
29 #' \item{\code{getLevel(index)}}{
30 #' Get level at specified index.}
31 #' \item{\code{getSerie(index)}}{
32 #' Get serie (centered+level) at specified index.}
33 #' \item{\code{getSeries(indices)}}{
34 #' Get series at specified indices (in columns).}
35 #' \item{\code{getExo(index)}}{
36 #' Get exogenous variables at specified index.}
37 #' \item{\code{getExoHat(index)}}{
38 #' Get estimated exogenous variables at specified index.}
41 Data = R6::R6Class("Data",
49 getStdHorizon = function()
50 24 - as.POSIXlt( private$.data[[1]]$time[1] )$hour + 1
52 append = function(new_time, new_centered_serie, new_level, new_exo, new_exo_hat)
54 private$.data[[length(private$.data)+1]] <- list(
55 "time"=new_time, "centered_serie"=new_centered_serie, "level"=new_level,
56 "exo"=new_exo, "exo_hat"=new_exo_hat)
58 getTime = function(index)
60 index = dateIndexToInteger(index, self)
61 private$.data[[index]]$time
63 getCenteredSerie = function(index)
65 index = dateIndexToInteger(index, self)
66 private$.data[[index]]$centered_serie
68 getCenteredSeries = function(indices)
69 sapply(indices, function(i) self$getCenteredSerie(i))
71 getLevel = function(index)
73 index = dateIndexToInteger(index, self)
74 private$.data[[index]]$level
76 getSerie = function(index)
78 index = dateIndexToInteger(index, self)
79 private$.data[[index]]$centered_serie + private$.data[[index]]$level
81 getSeries = function(indices)
82 sapply(indices, function(i) self$getSerie(i))
84 getExo = function(index)
86 index = dateIndexToInteger(index, self)
87 private$.data[[index]]$exo
89 getExoHat = function(index)
91 index = dateIndexToInteger(index, self)
92 private$.data[[index]]$exo_hat
94 removeFirst = function()
95 private$.data <- private$.data[2:length(private$.data)]
97 removeLast = function()
98 private$.data <- private$.data[1:(length(private$.data)-1)]