R code to measure 'velocity', how much each data point differs according to its neighbours. Accepts a vector and returns a single value measurement of velocity.
velocity <- function(vector) { | |
N <- length(vector) | |
val <- sum(abs(vector[1:N-1]-vector[2:N])) | |
return (val) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment