dat=read.csv("Z:/Download/dat.csv")
dat=dat[,c(2:13)]
str(dat)
## 'data.frame': 167 obs. of 12 variables:
## $ V1 : num 37 40 35 42 45 34 36 32 33 34 ...
## $ V2 : num 171 171 179 147 156 ...
## $ V3 : num 60.8 94.8 70.8 55.9 54.1 63.1 53.6 67.1 53.6 74.5 ...
## $ V4 : num 45.3 66.3 52.5 39.2 38.4 ...
## $ V5 : num 13 33.8 15.4 20 17.8 14.4 14.9 9.2 17.1 22.4 ...
## $ V6 : num 21.3 35.7 21.7 35.7 32.9 22.8 27.8 13.7 31.9 30 ...
## $ V7 : num 26.4 34.8 31 19.5 19.3 27.1 20.7 32.8 19.5 28.9 ...
## $ V6 : num 47.8 61 55.4 35.9 36.3 48.7 38.7 57.9 36.5 52.1 ...
## $ V9 : num 1.7 2.12 1.87 1.51 1.53 ...
## $ V10: num 20.9 32.6 22.2 25.8 22.1 ...
## $ V11: num 83 93 83 80 89 77 77 77 93 97 ...
## $ V12: num 349 351 350 351 349 ...
head(dat)
## V1 V2 V3 V4 V5 V6 V7 V6 V9 V10 V11 V12
## 1 37 170.6 60.8 45.3247 13.0 21.3 26.4 47.8 1.697423 20.89034 83 349.4
## 2 40 170.6 94.8 66.3183 33.8 35.7 34.8 61.0 2.119544 32.57244 93 351.0
## 3 35 178.6 70.8 52.5307 15.4 21.7 31.0 55.4 1.874158 22.19578 83 349.6
## 4 42 147.3 55.9 39.2252 20.0 35.7 19.5 35.9 1.512363 25.76359 80 351.1
## 5 45 156.3 54.1 38.3500 17.8 32.9 19.3 36.3 1.532593 22.14518 89 349.2
## 6 34 167.4 63.1 46.4747 14.4 22.8 27.1 48.7 1.712936 22.51741 77 343.9
1. Correlation network
1.1 qgraph package
library(qgraph)
cormat=cor(dat) # or cormat=cor(dat[,1:12],dat[,1:12])
qgraph(cormat,shape="circle", posCol="darkgreen", negCol="darkred", layout="groups", vsize=10)

1.2 Thay layout=“spring”
qgraph(cormat,shape="circle", posCol="darkgreen", negCol="darkred", layout="spring", vsize=10)

2. Correlation matrix
2.1 Corrplot package
(Ref: Applied Predictive Modeling)
library(corrplot)
cormat=cor(dat)
corrplot(cormat,order="hclust")

corrplot(cormat, type = "upper", order = "hclust",tl.col = "blue", tl.srt = 50)

For all variables (not good method for large number of variables)
chart.Correlation(dat, histogram=TRUE, pch=19)

For 5 variables only
chart.Correlation(dat[,c(1:5)], histogram=TRUE, pch=19)

2.3 Psych package
library(psych)
pairs.panels(dat)
