2
當我使用hclust函數時出現以下錯誤?我怎麼解決這個問題? 我使用Windows 7和2.12.3版本R.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)
請幫我解決這個問題。
請做一個可重現的例子(見這篇文章的提示:http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) – nullglob
正如nullglob所說。順便說一句,再讀一遍關於nullglob給你的鏈接的答案。運行你的代碼是不可能的,所以這不是一個可重複的例子。 –
以進行更多調試:嘗試使用'cat'打印索引編號,以便您輕鬆通過,以便您輕鬆分辨哪個表可以解決問題;然後使用'which(!is.finite(mat),arr.ind = TRUE)'來查看距離矩陣中的哪些元素是有問題的 –