r:correlation
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
r:correlation [2018/12/26 14:52] – hkimscil | r:correlation [2018/12/26 15:19] (current) – hkimscil | ||
---|---|---|---|
Line 5: | Line 5: | ||
< | < | ||
data(" | data(" | ||
- | my_data <- mtcars[, c(1, | + | my_data <- mtcars[, c(1,2, |
head(my_data) | head(my_data) | ||
</ | </ | ||
- | < | + | |
- | Mazda RX4 | + | |
- | Mazda RX4 Wag | + | |
- | Datsun 710 22.8 108 93 3.85 2.320 18.61 | + | |
- | Hornet 4 Drive 21.4 258 110 3.08 3.215 19.44 | + | |
- | Hornet Sportabout 18.7 360 175 3.15 3.440 17.02 | + | |
- | Valiant | + | |
< | < | ||
- | library(" | + | mpg cyl disp hp drat wt qsec |
- | rcorr(x, type = c(" | + | Mazda RX4 |
+ | Mazda RX4 Wag | ||
+ | Datsun 710 22.8 | ||
+ | Hornet 4 Drive 21.4 | ||
+ | Hornet Sportabout 18.7 | ||
+ | Valiant | ||
+ | > | ||
</ | </ | ||
< | < | ||
- | rcorr(my_data) | + | install.packages(" |
+ | library(Hmisc) | ||
+ | # rcorr(x, type = c(" | ||
+ | </ | ||
+ | |||
+ | < | ||
+ | rcorr(as.matrix(my_data)) | ||
+ | </ | ||
+ | < | ||
+ | > rcorr(as.matrix(my_data)) | ||
+ | | ||
+ | mpg 1.00 -0.85 -0.85 -0.78 0.68 -0.87 0.42 | ||
+ | cyl -0.85 1.00 0.90 0.83 -0.70 0.78 -0.59 | ||
+ | disp -0.85 0.90 1.00 0.79 -0.71 0.89 -0.43 | ||
+ | hp | ||
+ | drat 0.68 -0.70 -0.71 -0.45 1.00 -0.71 0.09 | ||
+ | wt | ||
+ | qsec 0.42 -0.59 -0.43 -0.71 0.09 -0.17 1.00 | ||
+ | |||
+ | n= 32 | ||
+ | |||
+ | |||
+ | P | ||
+ | | ||
+ | mpg | ||
+ | cyl 0.0000 | ||
+ | disp 0.0000 0.0000 | ||
+ | hp | ||
+ | drat 0.0000 0.0000 0.0000 0.0100 | ||
+ | wt | ||
+ | qsec 0.0171 0.0004 0.0131 0.0000 0.6196 0.3389 | ||
+ | > | ||
</ | </ |
r/correlation.txt · Last modified: 2018/12/26 15:19 by hkimscil