2016-12-06 109 views
0

我有以下數據集(DAT):在R中執行Mantel測試時如何解決「零距離」錯誤?

popfst  long  lat 
0.9   77.416667 23.25000 
0.2   -6.116667 36.70000 
0.3   -77.028333 -12.04333 
0.3   -86.929000 40.42400 

我希望在以下的數據執行Mantel檢驗。對於我所中的R

location.distance <- dist(cbind(dat$long,dat$lat)) 
genetic.distance <- dist(dat$popfst) 
as.matrix(location.distance)[1:4,1:4] 
as.matrix(genetic.distance)[1:4,1:4] 
mantel.rtest(location.distance, genetic.distance, nrepet = 9999) 

寫了下面的代碼。然而,當我運行的最後一行出現以下錯誤

Error in if (any(distmat < tol)) warning("Zero distance(s)") : 
missing value where TRUE/FALSE needed 

我不知道如何來糾正這個錯誤。我沒有看到other who have嘗試過這種類似的錯誤。有什麼建議麼?

回答

0

沒有必要在代碼這些行的,因爲Dist的輸出()是矩陣: as.matrix(location.distance)[1:4,1:4]

as.matrix (genetic.distance)[1:4,1:4]

另外,popfst列中有兩個值相等(0.3)。 所以距離爲0.

用更多小數點(0.345不等於0.322,因此距離大於0)請嘗試使用

相關問題