[R-sig-eco] How to convert matrix to paired list?
Peter Solymos
solymos at ualberta.ca
Fri Jul 24 02:35:05 CEST 2009
Dear Jin-Long,
You can try this:
x <- cbind(rnorm(10), rnorm(10), rnorm(10), rnorm(10))
y <- cor(x)
y
library(mefa)
z <- as.data.frame(as.dist(y))
z
Yours,
Peter
Peter Solymos, PhD
Postdoctoral Fellow
Department of Mathematical and Statistical Sciences
University of Alberta
Edmonton, Alberta, T6G 2G1
Canada
email <- paste("solymos", "ualberta.ca", sep = "@")
On Thu, Jul 23, 2009 at 4:49 PM, Zhang Jinlong<zhangjl at ibcas.ac.cn> wrote:
> Dear lists
> Suppose I have an correlation matrix of four places named "A","B","C"and"D", as below:
> A B C D
> A 0 0.5 0.2 0.8
> B 0.5 0 0.6 0.4
> C 0.2 0.6 0 0.4
> D 0.8 0.4 0.4 0
> Is there a function that allows me to generate the paired list like this?
> A B 0.5
> A C 0.2
> A D 0.8
> B C 0.6
> B D 0.4
> C D 0.4
> Could you help me if you know a method. Any suggestions will be appreciated.
> Thanks
> Jinlong
>
>
> Jin-Long ZHANG
> Ph.D. Candidate
> Institute of Botany
> Chinese Academy of Sciences
> Beijing 100093
> E-mail: zhangjl at ibcas.ac.cn
>
>
> [[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-ecology mailing list
> R-sig-ecology at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-ecology
>
>
More information about the R-sig-ecology
mailing list