[Vegan-commits] r1330 - in pkg/vegan: R inst
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Tue Oct 12 20:41:07 CEST 2010
Author: jarioksa
Date: 2010-10-12 20:41:06 +0200 (Tue, 12 Oct 2010)
New Revision: 1330
Modified:
pkg/vegan/R/oecosimu.R
pkg/vegan/R/print.oecosimu.R
pkg/vegan/inst/ChangeLog
Log:
na.rm = TRUE for handling simulated statistics in oecosimu
Modified: pkg/vegan/R/oecosimu.R
===================================================================
--- pkg/vegan/R/oecosimu.R 2010-10-12 18:15:06 UTC (rev 1329)
+++ pkg/vegan/R/oecosimu.R 2010-10-12 18:41:06 UTC (rev 1330)
@@ -95,12 +95,16 @@
}
}
## end of addition
- sd <- apply(simind, 1, sd)
- z <- (indstat - rowMeans(simind))/sd
+ sd <- apply(simind, 1, sd, na.rm = TRUE)
+ z <- (indstat - rowMeans(simind, na.rm = TRUE))/sd
if (any(sd < sqrt(.Machine$double.eps)))
z[sd < sqrt(.Machine$double.eps)] <- 0
- pless <- rowSums(indstat <= simind)
- pmore <- rowSums(indstat >= simind)
+ pless <- rowSums(indstat <= simind, na.rm = TRUE)
+ pmore <- rowSums(indstat >= simind, na.rm = TRUE)
+ if (any(is.na(simind))) {
+ warning("some simulated values were NA and were removed")
+ nsimul <- nsimul - rowSums(is.na(simind))
+ }
p <- switch(alternative,
two.sided = 2*pmin(pless, pmore),
less = pless,
Modified: pkg/vegan/R/print.oecosimu.R
===================================================================
--- pkg/vegan/R/print.oecosimu.R 2010-10-12 18:15:06 UTC (rev 1329)
+++ pkg/vegan/R/print.oecosimu.R 2010-10-12 18:41:06 UTC (rev 1330)
@@ -25,10 +25,15 @@
two.sided = c(0.025, 0.5, 0.975),
less = c(0, 0.5, 0.95),
greater = c(0.05, 0.5, 1))
- qu <- apply(x$oecosimu$simulated, 1, quantile, probs=probs)
+ qu <- apply(x$oecosimu$simulated, 1, quantile, probs=probs, na.rm = TRUE)
m <- cbind("statistic" = x$oecosimu$statistic,
"z" = x$oecosimu$z, t(qu),
"Pr(sim.)"=x$oecosimu$pval)
printCoefmat(m, ...)
+ if (any(is.na(x$oecosimu$simulated))) {
+ nacount <- rowSums(is.na(x$oecosimu$simulated))
+ cat("\nNumber of NA cases removed from simulations:\n",
+ nacount, "\n")
+ }
invisible(x)
}
Modified: pkg/vegan/inst/ChangeLog
===================================================================
--- pkg/vegan/inst/ChangeLog 2010-10-12 18:15:06 UTC (rev 1329)
+++ pkg/vegan/inst/ChangeLog 2010-10-12 18:41:06 UTC (rev 1330)
@@ -7,6 +7,10 @@
* treedive: handles trivial cases of zero (diversity NA) or one
species (diversity 0).
+ * oecosimu: handles NA values as na.rm = TRUE in simulations for
+ cases where these are produced by the function to evaluate
+ statistics.
+
* nestednodf: Gustavo Carvalho sent a new upgraded version which
also implements a new quantitative method of Almeida-Neto & Ulrich
(Env Mod Software, in press; 2010). Based on feature request #1097
More information about the Vegan-commits
mailing list