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 "missing"s :
> swM <- swiss
> colnames(swM) <- abbreviate(colnames(swiss), min=6)
> swM[1,2] <- swM[7,3] <- swM[25,5] <- NA # create 3 "missing"
> cor(swM, use = "na.or.complete")
           Frtlty      Agrclt     Exmntn      Eductn     Cathlc      Infn.M
Frtlty  1.0000000  0.37821953 -0.6548306 -0.67421581  0.4772298  0.38781500
Agrclt  0.3782195  1.00000000 -0.7127078 -0.64337782  0.4014837 -0.07168223
Exmntn -0.6548306 -0.71270778  1.0000000  0.69776906 -0.6079436 -0.10710047
Eductn -0.6742158 -0.64337782  0.6977691  1.00000000 -0.1701445 -0.08343279
Cathlc  0.4772298  0.40148365 -0.6079436 -0.17014449  1.0000000  0.17221594
Infn.M  0.3878150 -0.07168223 -0.1071005 -0.08343279  0.1722159  1.00000000
> # why isn't this the same?
> cor(swM[,c(1:2)], use = "na.or.complete")
          Frtlty    Agrclt
Frtlty 1.0000000 0.3920289
Agrclt 0.3920289 1.0000000

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to