Skip to content

Instantly share code, notes, and snippets.

@salmoni
Created August 19, 2013 14:48
Show Gist options
  • Save salmoni/6269948 to your computer and use it in GitHub Desktop.
Save salmoni/6269948 to your computer and use it in GitHub Desktop.
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