R/movmean.R

movmean <- function(x = x, w = w){
  i = 1
  temp.mean <- numeric(length(x))
  w <- w+1
  for(k in 1:w){
    if(i < w){
      temp.mean[k] <- mean(x[1:i])
    }
    i <- i + 1
  }
  temp.mean <- c(temp.mean, rollapply(x, w, mean))
  return(temp.mean)
}

Try the matrixProfile package in your browser

Any scripts or data that you put into this service are public.

matrixProfile documentation built on May 2, 2019, 9:43 a.m.