[R-sig-eco] Distance matrix based on correlation coefficient
Gavin Simpson
gavin.simpson at ucl.ac.uk
Tue Jul 20 21:42:54 CEST 2010
On Tue, 2010-07-20 at 12:12 -0700, Dragos Zaharescu wrote:
> I would much appreciate if someone would enlighten me on how to calculate a
> distance matrix based on correlation coefficient (Spearman)? The simple
> correlation matrix seems not to work.
In what sense did it not work? We aren't mind readers! Hence the posting
guide asking you to provide information that will help us to help you.
> I am trying to use it in FSO/MFSO to calculate the influence of
> climate factors on heavy metals concentrations.
Does this help at all?
> dat <- data.frame(A = rnorm(10), B = rnorm(10), C = rnorm(10))
> cor(dat)
A B C
A 1.00000000 0.08986947 0.1224007
B 0.08986947 1.00000000 0.2667838
C 0.12240068 0.26678381 1.0000000
> 1 - cor(dat) ## dissimilarity
A B C
A 0.0000000 0.9101305 0.8775993
B 0.9101305 0.0000000 0.7332162
C 0.8775993 0.7332162 0.0000000
> as.dist(1 - cor(dat))
A B
B 0.9101305
C 0.8775993 0.7332162
HTH
G
--
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
Dr. Gavin Simpson [t] +44 (0)20 7679 0522
ECRC, UCL Geography, [f] +44 (0)20 7679 0565
Pearson Building, [e] gavin.simpsonATNOSPAMucl.ac.uk
Gower Street, London [w] http://www.ucl.ac.uk/~ucfagls/
UK. WC1E 6BT. [w] http://www.freshwaters.org.uk
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
More information about the R-sig-ecology
mailing list