# NOT RUN {
## make a delta 2D (time series) function
delta <- rep(0,101)
delta[floor(length(delta)/2)] = 1
## define a window length to average over
win = 20
## filter the delta function...this will result in a boxcar
box.car <- run.avg(delta,win)
## note sum(box.car) should equal the sum of the original signal...
## in this case sum(box.car)==1
##############
## PLOTTING ##
##############
plot(delta,type='h',lwd=2)
lines(box.car,col='blue',lwd=2,type='h')
legend('topright',col=c('black','blue'),legend=c('delta','running average'),lwd=2)
# }
Run the code above in your browser using DataLab