X-Git-Url: https://git.auder.net/?p=talweg.git;a=blobdiff_plain;f=pkg%2FR%2FJ_Persistence.R;h=4d3abd2b100f595e1d329733614acc534cb25aca;hp=5d156cc3f8c429cea4a89c14ce7cd546d0b9bfa4;hb=72b9c50162bcdcf6c99fbb8b2ec6ea9ba98379cb;hpb=ed5977b22fb345f6586364c4e0ee841a4a600aaf diff --git a/pkg/R/J_Persistence.R b/pkg/R/J_Persistence.R index 5d156cc..4d3abd2 100644 --- a/pkg/R/J_Persistence.R +++ b/pkg/R/J_Persistence.R @@ -8,12 +8,13 @@ getPersistenceJumpPredict = function(data, today, memory, horizon, params, ...) #return gap between end of similar day curve and first day of tomorrow (in the past) first_day = max(1, today-memory) same_day = ifelse(hasArg("same_day"), list(...)$same_day, TRUE) + realtime = ifelse(hasArg("realtime"), list(...)$realtime, FALSE) index = today - ifelse(same_day,7,1) repeat { { last_serie_end = tail( data$getSerie(index), 1) - last_tomorrow_begin = data$getSerie(index+1)[1] + last_tomorrow_begin = data$getSerie(index+1,hat=(realtime && index+1==today))[1] index = index - ifelse(same_day,7,1) }; if (!is.na(last_serie_end) && !is.na(last_tomorrow_begin))