R/runsum.R

Defines functions runsum

Documented in runsum

#' runsum
#'
#' @param data input data
#' @param len the length
#' @param threshold the threshold
#'
#' @return returns a
#'
runsum = function(data, len, threshold){
  N = length(data)
  cnt = ceiling(N/len)
  rs = rep(0, cnt)

  for(n in 1:cnt){
    for(p in (1+len*(n-1)):(len*n)){
      if(p < N & data[p] >= threshold){
        rs[n] = rs[n] + data[p] - threshold
      }
    }
  }
  return(rs)
}

Try the activityCounts package in your browser

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

activityCounts documentation built on July 31, 2019, 9:04 a.m.