Skip to content
Prev 387068 / 398502 Next

dependent nested for loops in R

On 01/02/2021 7:03 a.m., Shaami wrote:
That's the same as

p <- 0.25
x <- rnorm(100)
z <- stats::filter(p*x, 1-p, init = 5, method="recursive")

This leaves z as a time series; if that causes trouble, follow it with

z <- as.numeric(z)

Duncan Murdoch