[R] Extract correlations from a matrix
John Kane
jrkrideau at yahoo.ca
Thu Nov 8 19:15:07 CET 2007
w[w>.6] seems to work for me. I cut down the size of
the matrix for easier visual inspection.
m=matrix(sample(1:20,replace=T),4,5)
w=cor(m,use="pairwise.complete.obs")
w
w[w>.6]
perhaps perferabely
w[w>0.6 & w!=1]
--- Christoph Scherber
<Christoph.Scherber at agr.uni-goettingen.de> wrote:
> Dear R users,
>
> suppose I have a matrix of observations for which I
> calculate all
> pair-wise correlations:
>
> m=matrix(sample(1:100,replace=T),10,10)
> w=cor(m,use="pairwise.complete.obs")
>
> How do I extract only those correlations that are
> >0.6?
>
> w[w>0.6] #obviously doesn´t work,
>
> and I can´t find a way around it.
>
> I would very much appreciate any help!
>
> Best wishes
> Christoph
>
>
> (using R 2.5.1 on Windows XP)
>
>
>
>
> --
> Dr. Christoph Scherber
> DNPW, Agroecology
> University of Goettingen
> Waldweg 26
> D-37073 Goettingen
> Germany
>
> phone +49(0)551 39 8807
> fax +49(0)551 39 8806
> homepage www.gwdg.de/~cscherb1
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained,
> reproducible code.
>
More information about the R-help
mailing list