[MORPHMET] pairwise matrix of vector angles in R

2017-11-03 Thread andrea cardini
Dear All, please, does anyone know if there's an R package that, using a matrix with several vectors (e.g., coefficients for allometric regressions in different taxa), will compute the pairwise (all possible pairs of taxa) matrix of vector angles? Thanks in advance for any suggestion. Cheers

Re: [MORPHMET] pairwise matrix of vector angles in R

2017-11-03 Thread Mike Collyer
Andrea, If you already have the matrix of coefficients, geomorph has an internal function that can do what you seek to do. You can try this geomorph:::vec.ang.matrix(myMatrix, type = “r”) # for vector correlations geomorph:::vec.ang.matrix(myMatrix, type = “rad”) # for vector angles in radians

Re: [MORPHMET] pairwise matrix of vector angles in R

2017-11-03 Thread David Katz
I think this does it (but please check; I quickly stuck together two different pieces of code)... # matrix where each vector is a row vec.mat <- ... #Compute group*loci matrix of mean microsatellite lengths angle.mat <- matrix(NA,nrow=nrow(vec.mat),ncol=nrow(vec.mat)) # angle function (radians con

Re: [MORPHMET] pairwise matrix of vector angles in R

2017-11-03 Thread Mike Collyer
Dear David, and others, Be careful with the code you just introduced here. There are a couple of mistakes. First, vectors need to be unit length. You code does not transform the vectors to unit length. Second, it’s the arccosine, the cosine of the vector inner product that finds the angle.