데이터 준비
library(caret)
## Loading required package: lattice
## Loading required package: ggplot2
R1 <- structure(c(1, 0.86, 0.56, 0.32, 0.85, 0.86, 1, 0.01, 0.74, 0.32,
0.56, 0.01, 1, 0.65, 0.91, 0.32, 0.74, 0.65, 1, 0.36,
0.85, 0.32, 0.91, 0.36, 1),
.Dim = c(5L, 5L))
colnames(R1) <- rownames(R1) <- paste0("x", 1:ncol(R1))
R1
## x1 x2 x3 x4 x5
## x1 1.00 0.86 0.56 0.32 0.85
## x2 0.86 1.00 0.01 0.74 0.32
## x3 0.56 0.01 1.00 0.65 0.91
## x4 0.32 0.74 0.65 1.00 0.36
## x5 0.85 0.32 0.91 0.36 1.00
findCorrelation(R1, exact=T, verbose=T)
## Compare row 5 and column 3 with corr 0.91
## Means: 0.61 vs 0.564 so flagging column 5
## All correlations <= 0.9
## [1] 5
먼저 0.61 구하기
R2 <- R1
diag(R2) <- NA
mean(R2[5, ], na.rm=T)
## [1] 0.61
그다음 0.564 구하기
mean(R2[-3, ], na.rm=T)
## [1] 0.564375