X-Git-Url: https://git.auder.net/?p=talweg.git;a=blobdiff_plain;f=pkg%2FR%2FForecast.R;h=bcafd3a26b60d7d41713987e77c2274ed340d285;hp=783e3522e5add869ae89e58b80e18680e991c54f;hb=98e958cab563866f8e00886b54336018a2e8bc97;hpb=af3b84f4cacade7d83221ca0249b546c50ddf340 diff --git a/pkg/R/Forecast.R b/pkg/R/Forecast.R index 783e352..bcafd3a 100644 --- a/pkg/R/Forecast.R +++ b/pkg/R/Forecast.R @@ -8,29 +8,31 @@ #' @field .pred List with \itemize{ #' \item serie: forecasted serie #' \item params: corresponding list of parameters (weights, neighbors...) -#' \item index: corresponding index in data object} +#' \item index_in_data: corresponding index in data object} #' @field .dates vector of day indices where forcast occurs #' -#' @section Methods: \describe{ -#' \item{\code{initialize(dates)}} -#' {Initialize a Forecast object with a series of date indices.} -#' \item{\code{getSize()}} -#' {Return number of individual forecasts.} -#' \item{\code{append(new_serie, new_params, new_index_in_data)}} -#' {Acquire a new individual forecast, with its (optimized) parameters and the corresponding +#' @section Methods: +#' \describe{ +#' \item{\code{initialize(dates)}}{ +#' Initialize a Forecast object with a series of date indices.} +#' \item{\code{getSize()}}{ +#' Return number of individual forecasts.} +#' \item{\code{append(new_serie, new_params, new_index_in_data)}}{ +#' Acquire a new individual forecast, with its (optimized) parameters and the corresponding #' index in the dataset.} -#' \item{\code{getDates()}} -#' {Get dates where forecast occurs.} -#' \item{\code{getSerie(index)}} -#' {Get forecasted serie at specified index.} -#' \item{\code{getParams(index)}} -#' {Get parameters at specified index (for 'Neighbors' method).} -#' \item{\code{getIndexInData(index)}} -#' {Get index in data which corresponds to current forecast.}} +#' \item{\code{getDates()}}{ +#' Get dates where forecast occurs.} +#' \item{\code{getSerie(index)}}{ +#' Get forecasted serie at specified index.} +#' \item{\code{getParams(index)}}{ +#' Get parameters at specified index (for 'Neighbors' method).} +#' \item{\code{getIndexInData(index)}}{ +#' Get index in data which corresponds to current forecast.} +#' } Forecast = R6::R6Class("Forecast", private = list( .pred = list(), - .dates = c() + .dates = integer(0) #store dates as integers (from 1970-01-01) ), public = list( initialize = function(dates) @@ -47,7 +49,7 @@ Forecast = R6::R6Class("Forecast", list("serie"=new_serie, "params"=new_params, "index_in_data"=new_index_in_data) }, getDates = function() - private$.dates + as.Date( private$.dates, origin="1970-01-01" ) , getSerie = function(index) {