Re: [R] find local max in moving window

2020-11-13 Thread Rui Barradas
Hello, The best option is package zoo, function(s) rollapply. p <- zoo::rollapply(nordn, width = 15, FUN = max, fill = c(NA, 0, NA)) These are meant as checks, see the differences between the one-liner above and your result. dim(position) length(p) w <- which(position[, 1] == p) position[

[R] find local max in moving window

2020-11-13 Thread ani jaya
Dear r list, I try to locate any local max value and location of data that follow 7 moving window condition, meaning that this data is largest and centered in 7 values to the left and 7 values to the right. I can solve it by using for and if function, like below: dput(nordn) c(`1` = 36.3167318892