Created
August 19, 2013 14:48
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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