[R] a question regarding 'cor' function

Tao Shi shitao at hotmail.com
Fri Mar 5 07:43:18 CET 2004


I'm a little bit confused with how exactly the 'cor' function handles 
missing values.  Should the last two function calls give the same results?   
Thanks,
...Tao

==========================================
>x=rnorm(10)
>y=rnorm(10)
>x[1]=NA
>y[2]=NA
>cor(x,y,method="spearman")
[1] -0.006060606

>cor(x,y,use="pairwise.complete.obs",method="spearman")
[1] -0.006060606
>cor(x[3:10],y[3:10],method="spearman")
[1] 0.1666667
==========================================

_________________________________________________________________
Create a Job Alert on MSN Careers and enter for a chance to win $1000! 
http://msn.careerbuilder.com/promo/kaday.htm?siteid=CBMSN_1K&sc_extcmp=JS_JASweep_MSNHotm2




More information about the R-help mailing list