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 converted to degrees)
vec.angle <- function(v1,v2){cos(t(v1)%*%v2)*57.2958}
# angles-to-matrix loop
for(i in 1:nrow(vec.mat))
{
  for(j in 1:nrow(vec.mat))
  {
    # angle bw vec1 and vec2
    angle.mat[i, j] <- vec.angle(vec.mat[i,], vec.mat[j,])}
}
return(angle.mat)
}

On Fri, Nov 3, 2017 at 2:38 AM, andrea cardini <alcard...@gmail.com> wrote:

> 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
>
> Andrea
>
>
> --
>
> Dr. Andrea Cardini
> Researcher, Dipartimento di Scienze Chimiche e Geologiche, Università di
> Modena e Reggio Emilia, Via Campi, 103 - 41125 Modena - Italy
> <https://maps.google.com/?q=Emilia,+Via+Campi,+103+-+41125+Modena+-+Italy&entry=gmail&source=g>
> tel. 0039 059 2058472
>
> Adjunct Associate Professor, School of Anatomy, Physiology and Human
> Biology, The University of Western Australia, 35 Stirling Highway, Crawley
> WA 6009, Australia
>
> E-mail address: alcard...@gmail.com, andrea.card...@unimore.it
> WEBPAGE: https://sites.google.com/site/alcardini/home/main
>
> FREE Yellow BOOK on Geometric Morphometrics:
> http://www.italian-journal-of-mammalogy.it/public/journals/3
> /issue_241_complete_100.pdf
>
> ESTIMATE YOUR GLOBAL FOOTPRINT: http://www.footprintnetwork.or
> g/en/index.php/GFN/page/calculators/
>
> --
> MORPHMET may be accessed via its webpage at http://www.morphometrics.org
> --- You received this message because you are subscribed to the Google
> Groups "MORPHMET" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to morphmet+unsubscr...@morphometrics.org.
>
>


-- 
David C. Katz, Ph.D.
Postdoctoral Fellow
Benedikt Hallgrimsson Lab
University of Calgary

Research Associate
Department of Anthropology
University of California, Davis

ResearchGate profile <https://www.researchgate.net/profile/David_Katz29>
Personal webpage
<https://davidckatz.wordpress.com/>

-- 
MORPHMET may be accessed via its webpage at http://www.morphometrics.org
--- 
You received this message because you are subscribed to the Google Groups 
"MORPHMET" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to morphmet+unsubscr...@morphometrics.org.

Reply via email to