R, TRUE/FALSE needed in FindCorrelation

Viewed 2646

I've created a simple correlation matrix in R and I'm trying to use caret for feature selection so I can remove the highly correlated X attributes.

Here is my code:

highlyCorrelated <- findCorrelation(correlationMatrix, cutoff = 0.90, verbose = FALSE, names = TRUE, exact = ncol(correlationMatrix) < 100)
  • highlyCorrelated is the name for the new object
  • correlationMatrix is the name of my correlation matrix

I'm getting the following error regardless of how I enter the function into R. Even if I only use one parameter I still get this error:

Error in if (x[i, j] > cutoff) { : missing value where TRUE/FALSE needed

Any thoughts?

2 Answers

I had the same problem. In my case the issue was, Infinite values in my data, which use='complete.obs' doesn't account for in cor().

Solved it by preprocessing the data with

data <- apply(data, 2, function(y) {y[!is.finite(y)]=NA; y})
Related