6 #' @importFrom R6 R6Class
8 #' @field .data List of
10 #' \item time: vector of times
11 #' \item centered_serie: centered series
12 #' \item level: corresponding levels
13 #' \item exo: exogenous variables
14 #' \item exo_hat: predicted exogenous variables
19 #' \item{\code{getSize()}}{
20 #' Return number of series in dataset.}
21 #' \item{\code{getStdHorizon()}}{
22 #' Return number of time steps from serie[1] until midnight}
23 #' \item{\code{appendHat(time, exo_hat)}}{
24 #' New estimated exogenous variables + time}
25 #' \item{\code{append(serie, exo)}}{
26 #' New measured data; call *after* \code{appendHat()}}
27 #' \item{\code{getTime(index)}}{
28 #' Get times at specified index.}
29 #' \item{\code{getCenteredSerie(index)}}{
30 #' Get (measured or predicted) centered serie at specified index.}
31 #' \item{\code{getCenteredSeries(indices)}}{
32 #' Get centered series at specified indices (in columns).}
33 #' \item{\code{getLevel(index)}}{
34 #' Get level at specified index.}
35 #' \item{\code{getSerie(index)}}{
36 #' Get serie (centered+level) at specified index.}
37 #' \item{\code{getSeries(indices)}}{
38 #' Get series at specified indices (in columns).}
39 #' \item{\code{getExoHat(index)}}{
40 #' Get predicted exogenous variables at specified index.}
41 #' \item{\code{getExo(index)}}{
42 #' Get exogenous variables at specified index.}
43 #' \item{\code{removeFirst()}}{
44 #' Remove first list element (if truncated).}
45 #' \item{\code{removeLast()}}{
46 #' Remove last list element (if truncated).}
49 Data = R6::R6Class("Data",
57 getStdHorizon = function()
58 24 - as.POSIXlt( private$.data[[1]]$time[1] )$hour + 1
60 append = function(time, exo_hat)
61 private$.data[[length(private$.data)+1]] <- list("time"=time,"exo_hat"=exo_hat)
63 append = function(time, serie, exo)
65 index <- length(private$.data)
66 level = mean(serie, na.rm=TRUE)
67 centered_serie = serie - level
68 private$.data[[index]]$time <- time
69 private$.data[[index]]$centered_serie <- centered_serie
70 private$.data[[index]]$level <- level
71 private$.data[[index]]$exo <- exo
73 getTime = function(index)
75 index = dateIndexToInteger(index, self)
76 private$.data[[index]]$time
78 getCenteredSerie = function(index)
80 index = dateIndexToInteger(index, self)
81 private$.data[[index]]$centered_serie
83 getCenteredSeries = function(indices)
84 sapply(indices, function(i) self$getCenteredSerie(i))
86 getLevel = function(index)
88 index = dateIndexToInteger(index, self)
89 private$.data[[index]]$level
91 getSerie = function(index)
93 index = dateIndexToInteger(index, self)
94 private$.data[[index]]$centered_serie + private$.data[[index]]$level
96 getSeries = function(indices)
97 sapply(indices, function(i) self$getSerie(i))
99 getExoHat = function(index)
101 index = dateIndexToInteger(index, self)
102 private$.data[[index]]$exo_hat
104 getExo = function(index)
106 index = dateIndexToInteger(index, self)
107 private$.data[[index]]$exo
109 removeFirst = function()
110 private$.data <- private$.data[2:length(private$.data)]
112 removeLast = function()
113 private$.data <- private$.data[1:(length(private$.data)-1)]