[R] Remove highly correlated variables from a data frame or matrix

Jim Lemon drj|m|emon @end|ng |rom gm@||@com
Fri Nov 15 21:17:50 CET 2019


While the remedy for your dissatisfaction with my previous solution
should be obvious, I will make it explicit.

# that is rows containing at most one value > 0.8
# ignoring the diagonal
keeprows<-apply(ro246,1,function(x) return(sum(x>0.8)<2))
ro246.lt.8<-ro246[keeprows,keeprows]

Jim



More information about the R-help mailing list