[Picante-commits] r69 - pkg/R
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Thu May 22 02:10:45 CEST 2008
Author: skembel
Date: 2008-05-22 02:10:45 +0200 (Thu, 22 May 2008)
New Revision: 69
Modified:
pkg/R/phylodiversity.R
Log:
Fixed mnnd to deal with samples with a single species
Modified: pkg/R/phylodiversity.R
===================================================================
--- pkg/R/phylodiversity.R 2008-05-21 22:24:50 UTC (rev 68)
+++ pkg/R/phylodiversity.R 2008-05-22 00:10:45 UTC (rev 69)
@@ -66,9 +66,14 @@
mnnd <- numeric(N)
for (i in 1:N) {
sppInSample <- names(samp[i,samp[i,]>0])
- sample.dis <- dis[sppInSample,sppInSample]
- diag(sample.dis) <- NA
- mnnd[i] <- mean(apply(sample.dis,2,min,na.rm=TRUE))
+ if (length(sppInSample) > 1) {
+ sample.dis <- dis[sppInSample,sppInSample]
+ diag(sample.dis) <- NA
+ mnnd[i] <- mean(apply(sample.dis,2,min,na.rm=TRUE))
+ }
+ else {
+ mnnd[i] <- 0
+ }
}
mnnd
}
More information about the Picante-commits
mailing list