Skip to content

Instantly share code, notes, and snippets.

@rukku
Created February 16, 2012 08:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rukku/1843347 to your computer and use it in GitHub Desktop.
Save rukku/1843347 to your computer and use it in GitHub Desktop.
Computes the angle between two vectors in R
theta <- acos( sum(a*b) / ( sqrt(sum(a * a)) * sqrt(sum(b * b)) ) )
#taken from http://stackoverflow.com/questions/1897704/angle-between-two-vectors-in-r
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment