[R] Spearman's Rho Help!

Joost van Evert joostvanevert at gmail.com
Tue Oct 25 10:48:07 CEST 2005


On Mon, 2005-10-24 at 09:01 -0400, Suresh Kumar Karanam wrote:
> Hi,
> I have a dataset with four categories of data, the number of samples are not 
> the same in each category. I want to find the Spearaman's Rho. Let me give 
> an example.
> x=(14.22770439,26.49420624,46.7277932,19.02550707,23.37379361,16.97789862,19.77100085,23.11270162,13.72929843,33.54430621,14.4756979,70.15811106,11.22789833,NA,NA,NA)
> y=(143.2420241,45.24260203,62.13218994,27.79050219,27.41029595,191.2759927,141.1430225,234.1600259,37.69120463,156.332942,19.98579421,34.77930022,69.90888888,21.92539608,NA,NA)
> z=(70.28027834,349.7838817,29.81811184,83.48042267,52.47989761,107.7110162,71.24609317,155.6580091,68.37158664,156.3179887,134.8930305,80.25242044,100.5309559,266.4470408,65.4934171,22.86950128)
> v=(150.2099947,73.52000706,83.18122348,150.3240468,352.9101222,195.8919089,263.9489287,114.2090369,153.5000165,18.62309563,117.2399949,441.8981252,285.3369951,161.3959985,NA,NA)
> I want to find the spearman's rho for this data. To my knowledge spearman's 
> rho is for x vs. y or x vs. z or any combination. Is there a spearman's rho 
> for the data all together (x y z v)? Please help!
e.g.
cor(array(c(x,y,z,v),c(16,4)),use="pairwise")

The correlation function calculates by default spearman's rho and can
have an array as input. The use parameter determines how to handle NA's.
See ?cor

Joost




More information about the R-help mailing list