t <- 1:9
x <- c(0, 2, 0, 4, 4, 4, 0, 2, 0)
x - detrend(x, 'constant')
x - detrend(x, 'linear')
y <- detrend(x, 'linear', 5)
## Not run:
# plot(t, x, col="blue")
# lines(t, x - y, col="red")
# grid()## End(Not run)
Run the code above in your browser using DataLab