7

I would like to make a correlation matrix like the one below. However, R keeps telling me

'Error in eigen(corr) : infinite or missing values in 'x''

Correlation matrix circles

I think this may be caused by NA values in my matrix. However, when I try to remove them by adding

'na.rm=TRUE,' it doesnt seem to help

circle.corr( cor(Plant, na.rm=TRUE,), order = TRUE, bg = "gray50", 
    col = colorRampPalette(c("blue","white","red"))(100) )

I have already loaded the function provided in the link above

Is it possible to create a new data.frame with the NA's removed? if so, how?

user1977802
  • 313
  • 6
  • 10
  • 18

1 Answers1

5

Without data is hard to help you , but the error because your correlation matrix contains NA and eigen can't compute the eigen values in this cases.

This should work :

circle.corr( cor(Plant,use = "complete.obs"),   # NA are removed
      order = TRUE, bg = "gray50",
      col = colorRampPalette(c("blue","white","red"))(100) )
agstudy
  • 119,832
  • 17
  • 199
  • 261
  • 1
    I get this error: Error in cor(Plant, na.rm = TRUE) : unused argument(s) (na.rm = TRUE) for future reference, how can I easily provide data to future posts? – user1977802 Feb 03 '13 at 16:46
  • 1
    you can use `dput(Plant)` ..more general you can see [this](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example). The error you got because you add `na.rm= TRUE ` in `circle.corr` call. I update my answer. – agstudy Feb 03 '13 at 16:48
  • I am still getting the same error: Error in cor(Plant, na.rm = T) : unused argument(s) (na.rm = T), even when I use your updated code – user1977802 Feb 03 '13 at 17:07
  • @user1977802 I am sorry I read the help of var ...for cor you use the argument `use`. It is better to add to add your data like I showed you before. – agstudy Feb 03 '13 at 17:27
  • You might want to look at the `nearZeroVar` function in the caret package. – screechOwl Oct 11 '17 at 19:20