[R] cor
Peter B. Mandeville
mandevip at uaslp.mx
Tue Nov 11 20:51:11 CET 2003
Greetings:
It would seem to me that the three arguments "a", "c" and "p" ought to
produce the same result with a data frame that doesn't have any missing
data which is not the case. What am I doing wrong or what don't I understand?
> tmp <- data.frame(vol,con,mot,esp,pri,sec)
> tmp
vol con mot esp pri sec
1 1.00 120 90 78 21 1
2 0.50 60 25 80 15 5
3 0.50 50 40 52 46 2
4 1.00 257 60 78 20 2
5 0.50 150 85 85 11 4
6 0.50 113 5 79 18 3
7 0.50 117 60 67 30 3
8 1.00 193 60 74 23 3
9 0.50 139 60 50 46 4
10 0.50 144 70 67 31 2
11 1.00 127 80 47 41 12
12 0.50 200 80 42 40 18
13 0.75 106 40 58 33 9
14 0.50 127 30 61 28 11
15 0.50 200 50 51 45 4
16 1.00 229 80 70 27 3
17 0.75 207 50 62 28 10
18 0.25 63 30 60 35 5
19 1.00 58 80 67 29 4
> cor(tmp)
vol con mot esp pri sec
vol 1.00000000 0.36263681 0.52616642 0.21163185 -0.21149234 -0.09813069
con 0.36263681 1.00000000 0.34665834 0.02016283 -0.07877831 0.12922310
mot 0.52616642 0.34665834 1.00000000 -0.04678632 0.04038370 0.03675419
esp 0.21163185 0.02016283 -0.04678632 1.00000000 -0.94112303 -0.60128659
pri -0.21149234 -0.07877831 0.04038370 -0.94112303 1.00000000 0.29576002
sec -0.09813069 0.12922310 0.03675419 -0.60128659 0.29576002 1.00000000
> cor(tmp,use="a")
vol con mot esp pri sec
vol 1.00000000 0.36263681 0.52616642 0.21163185 -0.21149234 -0.09813069
con 0.36263681 1.00000000 0.34665834 0.02016283 -0.07877831 0.12922310
mot 0.52616642 0.34665834 1.00000000 -0.04678632 0.04038370 0.03675419
esp 0.21163185 0.02016283 -0.04678632 1.00000000 -0.94112303 -0.60128659
pri -0.21149234 -0.07877831 0.04038370 -0.94112303 1.00000000 0.29576002
sec -0.09813069 0.12922310 0.03675419 -0.60128659 0.29576002 1.00000000
> cor(tmp,use="c")
vol con mot esp pri sec
vol 1.00000000 0.36263681 0.52616642 0.21163185 -0.21149234 -0.09813069
con 0.36263681 1.00000000 0.34665834 0.02016283 -0.07877831 0.12922310
mot 0.52616642 0.34665834 1.00000000 -0.04678632 0.04038370 0.03675419
esp 0.21163185 0.02016283 -0.04678632 1.00000000 -0.94112303 -0.60128659
pri -0.21149234 -0.07877831 0.04038370 -0.94112303 1.00000000 0.29576002
sec -0.09813069 0.12922310 0.03675419 -0.60128659 0.29576002 1.00000000
> cor(tmp,use="p")
vol con mot esp pri sec
vol 1.0000000 0.35898321 0.33585184 0.26418611 0.31817707 0.34311708
con 0.3589832 0.99240991 0.34399506 0.02035910 -0.07698392 0.12891702
mot 0.3358518 0.34399506 0.98480785 0.04365569 0.08719418 0.05687228
esp 0.2641861 0.02035910 0.04365569 0.99985490 -0.85247286 -0.55912698
pri 0.3181771 -0.07698392 0.08719418 -0.85247286 0.98445398 0.30189124
sec 0.3431171 0.12891702 0.05687228 -0.55912698 0.30189124 0.95034447
Thank you very much,
Peter B.
More information about the R-help
mailing list