e.rapsomaniki@mail.cryst.bbk.ac.uk
2005-Oct-02 09:04 UTC
[R] convering upper triangular matrix into vector
Hi I have two symmetrical distance matrices and want to compute the correlation coefficient between them (after turning them into vectors). Is there a way of selecting only the upper triangular part of each matrix, then convert this into a vector so I can compute the correlation? Many Thanks Eleni Rapsomaniki
e.rapsomaniki at mail.cryst.bbk.ac.uk writes:> Hi > > I have two symmetrical distance matrices and want to compute the correlation > coefficient between them (after turning them into vectors). > > Is there a way of selecting only the upper triangular part of each matrix, then > convert this into a vector so I can compute the correlation?X[upper.tri(X)] (as help.search("triangular") would have told you soon enough) -- O__ ---- Peter Dalgaard ??ster Farimagsgade 5, Entr.B c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907
Dimitris Rizopoulos
2005-Oct-02 10:24 UTC
[R] convering upper triangular matrix into vector
look at: '?upper.tri()' Best, Dimitris ---- Dimitris Rizopoulos Ph.D. Student Biostatistical Centre School of Public Health Catholic University of Leuven Address: Kapucijnenvoer 35, Leuven, Belgium Tel: +32/(0)16/336899 Fax: +32/(0)16/337015 Web: http://www.med.kuleuven.be/biostat/ http://www.student.kuleuven.be/~m0390867/dimitris.htm ----- Original Message ----- From: <e.rapsomaniki at mail.cryst.bbk.ac.uk> To: <R-help at stat.math.ethz.ch> Sent: Sunday, October 02, 2005 11:04 AM Subject: [R] convering upper triangular matrix into vector> Hi > > I have two symmetrical distance matrices and want to compute the > correlation > coefficient between them (after turning them into vectors). > > Is there a way of selecting only the upper triangular part of each > matrix, then > convert this into a vector so I can compute the correlation? > > Many Thanks > Eleni Rapsomaniki > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! > http://www.R-project.org/posting-guide.html >Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm