[R] Spearman rank-order correlation matrix

Russell Senior seniorr at aracnet.com
Tue May 7 01:52:32 CEST 2002


I"ve got a data frame with a selection of columns I want to compute a
rank-order correlation matrix from without disturbing the original
data frame.

  foo[,c("a","b","d","f","g")]

What I wanted to do, intuitively, was:

  > cor(rank(foo[,c("a","b","d","f","g")]))

but rank in that context ranks all of the values from the matrix
together as one long vector.  I want the columns (and their names) to
be preserved, just replacing the value with its rank.  What is the
most direct way to get what I want?

Thanks!

-- 
Russell Senior         ``The two chiefs turned to each other.        
seniorr at aracnet.com      Bellison uncorked a flood of horrible       
                         profanity, which, translated meant, `This is
                         extremely unusual.' ''                      
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list