Add report generator + first draft of report.gj
[talweg.git] / talweg / R / F_Average.R
... / ...
CommitLineData
1#' @include Forecaster.R
2#'
3#' Average Forecaster
4#'
5#' Return the (pointwise) average of the all the (similar) centered day curves
6#' in the past. Inherits \code{\link{Forecaster}}
7AverageForecaster = R6::R6Class("AverageForecaster",
8 inherit = Forecaster,
9
10 public = list(
11 predictShape = function(data, today, memory, horizon, ...)
12 {
13 avg = rep(0., horizon)
14 first_day = max(1, today-memory)
15 index = today-7 + 1
16 nb_no_na_series = 0
17 repeat
18 {
19 {
20 serie_on_horizon = data$getCenteredSerie(index)[1:horizon]
21 index = index - 7
22 };
23 if (!any(is.na(serie_on_horizon)))
24 {
25 avg = avg + serie_on_horizon
26 nb_no_na_series = nb_no_na_series + 1
27 };
28 if (index < first_day)
29 break
30 }
31 avg / nb_no_na_series
32 }
33 )
34)