R/pipe.diff.R

pipe.diff <- function(input, initial = 0){
  processor(
    input,
    prepare = function(env){
      SI.is.channels(input) || stop("Input must be channels")
      
      env$init <- matrix(initial, ncol=SI(input)$channels, nrow=1)
      
      SI(input)
    },
    online = function(input){
      
      ret <- diff(rbind(init, input))
      attr(ret, 'TS') <- attr(input, 'TS')
      init <<- input[nrow(input),]
      
      ret
    }
  )
}
tz-lom/Resonance-Rproj documentation built on July 1, 2019, 4:53 p.m.