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)
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?
I had the same problem and @user20650 answer was correct. I always do the same "preprocess" to ensure finCorrelation works:
nums <- sapply(data, is.numeric)
data.numeric <- data[ , nums]
data.without_na <- na.omit(data.numeric)
cor_matrix <- cor(data.without_na)
findCorrelation(cor_matrix, 0.7)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With