R/mySmooth.R

Defines functions mySmooth

### smooth the value of vec
mySmooth <- function(vec, windlen = 3){
  cum = cumsum(vec)
  n = length(cum)
  a = c(cum[((windlen - 1)/2 + 1):n],
        rep(cum[n], (windlen - 1)/2))
  b = c(rep(0, (windlen - 1)/2 + 1),
        cum[seq_len((n - (windlen - 1)/2 -1))])
  res = (a-b)/windlen
  return(res)
}
ZhenxingGuo0015/TRESS documentation built on April 14, 2023, 4:21 p.m.