Reputation: 21
I am getting the following error when I use hclust function? How can I solve this problem? I am using windows 7 and 2.12.3 version of R.
n_seq <- 250
mat <- matrix(NA, ncol=n_seq, nrow=n_seq)
for (idx in 1:n_seq)
{mat[idx,idx] <- 0.0}
for(idx in 1:(n_seq-1) )
{intemp <- read.xls("C:// clustal.xls", sheet = idx );
mat[(1+idx):n_seq,idx] <- intemp[1:(n_seq-idx), 11]}
fit <- hclust(as.dist(mat), method="single")
Error in hclust(as.dist(mat), method = "single") :
NA/NaN/Inf in foreign function call (arg 11)
Please help me to solve this problem.
Upvotes: 2
Views: 5351
Reputation: 7023
This error message arises because the distance matrix as.dist(mat)
has a bad value (NA
, NaN
or Inf
) in it. If you look in the code of hclust
, the 11th argument to the foreign function call (i.e. by compiled code) is the values of the distance matrix, and this is what R is complaining about. By default, NA
, NaN
or Inf
are not accepted by foreign function calls. See ?.Fortran
for more info.
Upvotes: 4