taiyun / corrplot

A visual exploratory tool on correlation matrix
https://github.com/taiyun/corrplot
Other
316 stars 86 forks source link

Error in hclust(as.dist(1 - corr), method = hclust.method) : NA/NaN/Inf in foreign function call (arg 10) #244

Closed UNFPAmaldives closed 2 years ago

UNFPAmaldives commented 2 years ago

I'm using R 4.1.2 in RStudio with corrplot 0.92. When I run the following:

general_df = data.frame(matrix(rnorm(20), nrow=10))

library(corrplot)
M <- cor (general_df)
corrplot(M, type = 'upper')

general_log <- cor (log (general_df))
corrplot (general_log, order = "hclust", addrect = 5, 
          method = 'ellipse', title = 'FPC: Log-Transform')

This returns the error:

Error in hclust(as.dist(1 - corr), method = hclust.method) : 
  NA/NaN/Inf in foreign function call (arg 10)

There are obviously no NA/NaN/Inf rows or columns in my data set. How do I fix this problem?

taiyun commented 2 years ago
> general_log 
   X1 X2
X1  1 NA
X2 NA  1