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.}
40 Data = R6::R6Class("Data",
48 getStdHorizon = function()
49 24 - as.POSIXlt( private$.data[[1]]$time[1] )$hour + 1
51 append = function(new_time, new_centered_serie, new_level, new_exo, new_exo_hat)
53 private$.data[[length(private$.data)+1]] <- list(
54 "time"=new_time, "centered_serie"=new_centered_serie, "level"=new_level,
55 "exo"=new_exo, "exo_hat"=new_exo_hat)
57 getTime = function(index)
59 index = dateIndexToInteger(index, self)
60 private$.data[[index]]$time
62 getCenteredSerie = function(index)
64 index = dateIndexToInteger(index, self)
65 private$.data[[index]]$centered_serie
67 getCenteredSeries = function(indices)
68 sapply(indices, function(i) self$getCenteredSerie(i))
70 getLevel = function(index)
72 index = dateIndexToInteger(index, self)
73 private$.data[[index]]$level
75 getSerie = function(index)
77 index = dateIndexToInteger(index, self)
78 private$.data[[index]]$centered_serie + private$.data[[index]]$level
80 getSeries = function(indices)
81 sapply(indices, function(i) self$getSerie(i))
83 getExo = function(index)
85 index = dateIndexToInteger(index, self)
86 private$.data[[index]]$exo
88 getExoHat = function(index)
90 index = dateIndexToInteger(index, self)
91 private$.data[[index]]$exo_hat
93 removeFirst = function()
94 private$.data <- private$.data[2:length(private$.data)]
96 removeLast = function()
97 private$.data <- private$.data[1:(length(private$.data)-1)]