2016-12-06 33 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)请尝试使用

相关问题