Re: [R] correlation with missing values.. different answers

2014-04-14 Thread peter dalgaard
On 14 Apr 2014, at 05:02 , Paul Tanger paul.tan...@colostate.edu wrote: Thanks, I did not realize it was deleting rows! I was afraid to try pairwise.complete.obs because it said something about resulting in a matrix which is not positive semi-definite (and googling that term just confused

[R] correlation with missing values.. different answers

2014-04-13 Thread Paul Tanger
Hi, I can't seem to figure out why this gives me different answers. Probably something obvious, but I thought they would be the same. This is an minimal example from the help page of cor() : ## swM := swiss with 3 missings : swM - swiss colnames(swM) - abbreviate(colnames(swiss), min=6)

Re: [R] correlation with missing values.. different answers

2014-04-13 Thread Jeff Newmiller
Please post in plain text per the Posting Guide. Read ?cor, particularly the part about complete.cases. Your two cases have different effective input rows. --- Jeff NewmillerThe . .

Re: [R] correlation with missing values.. different answers

2014-04-13 Thread arun
Hi, I think in this case, when you use na.or.complete, all the NA rows are removed for the full dataset. cor(swM[-1,1:2]) # FrtltyAgrclt  #Frtlty 1.000 0.3920289 #Agrclt 0.3920289 1.000 cor(swM[-1,])[1:2,1:2] #FrtltyAgrclt #Frtlty 1.000 0.3920289 #Agrclt

Re: [R] correlation with missing values.. different answers

2014-04-13 Thread Paul Tanger
Thanks, I did not realize it was deleting rows! I was afraid to try pairwise.complete.obs because it said something about resulting in a matrix which is not positive semi-definite (and googling that term just confused me more). But I ran the dataset through JMP and got the same answers so I