Skip to content

Commit 29359b2

Browse files
Fixed recycling warning in generate() method for SNAIVE() models
Resolves #436
1 parent 2964064 commit 29359b2

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

NEWS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
* Fixed `VARIMA()` not working with integer data.
1111
* More robust calculations of `ARIMA()` AR and MA roots (#417).
1212
* Fixed `refit()` method for `ETS()` models applying transformations twice (#407).
13+
* Fixed recycling warning in `generate()` method for `SNAIVE()` models (#436).
1314

1415
# fable 0.4.1
1516

R/lagwalk.R

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -286,8 +286,11 @@ generate.RW <- function(x, new_data, bootstrap = FALSE, ...) {
286286
dx <- e + b
287287
lag_grp <- rep_len(seq_len(lag), length(dx))
288288
dx <- split(dx, lag_grp)
289-
cumulative_e <- unsplit(lapply(dx, cumsum), lag_grp)
290-
rep_len(future, length(dx)) + cumulative_e
289+
290+
unsplit(
291+
.mapply(function(x, i) cumsum(x) + i, list(dx, future), NULL),
292+
lag_grp
293+
)
291294
}
292295

293296
transmute(group_by_key(new_data), ".sim" := sim_rw(!!sym(".innov")))

0 commit comments

Comments
 (0)