Skip to content

Instantly share code, notes, and snippets.



Created Aug 19, 2013
What would you like to do?
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