A data.frame contains a measurement of some value and a time when it was recorded like this
df <- data.frame(time=1:1000, v=sin(1:1000))
I plot the derivation of v
library(zoo)
plot(x=(rollmean(df$time,k=2)), y=diff(df$v,k=2))
This method works somehow for a small matrix and if k=2, but for more complicate situations with derivation over 5 values diff(df$v, k=5) and many columns it is not very handy.
Is there a better more flexible and direct solution?
I am not sure to understand your problem , but something like this can maybe help