我正在尝试获取一组DNA样品的多样性统计信息,但是却收到此错误代码:min.dist [names(hap.vec)[is.na(hap.vec)]中的错误,drop = FALSE ]:下标超出范围。
stratastat<-function(x,pop=pop,fun=nuc.div){
#this function will calculate stats for a DNAbin object (x), stratified across populations given in pop.
# Some functions this will work with: nuc.div(), theta.s(), tajima.test() from pegas, FusFs(), exptdHet() from strataG,
stats<-NULL
for(p in unique(pop)){
stat<-fun(pis[grep(p,names(pis))])
stats<-c(stats,stat)
}
names(stats)<-unique(pop)
return(stats)
}
stratastat(pis,pop=pop,fun=nuc.div)
stratastat(pis,pop=pop,fun=fusFs)