[Vegan-commits] r1682 - in pkg/vegan: R inst man

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sun Jul 17 08:25:09 CEST 2011


Author: jarioksa
Date: 2011-07-17 08:25:09 +0200 (Sun, 17 Jul 2011)
New Revision: 1682

Modified:
   pkg/vegan/R/swan.R
   pkg/vegan/inst/ChangeLog
   pkg/vegan/man/beals.Rd
Log:
swan gained argument maxit (defaults Inf)

Modified: pkg/vegan/R/swan.R
===================================================================
--- pkg/vegan/R/swan.R	2011-07-16 12:26:47 UTC (rev 1681)
+++ pkg/vegan/R/swan.R	2011-07-17 06:25:09 UTC (rev 1682)
@@ -1,10 +1,13 @@
 swan <-
-function (x)
+function (x, maxit = Inf)
 {
     zeros <- -Inf
-    while(zeros != (zeros <- sum(x == 0)) && any(x == 0)) {
+    iter <- 0
+    while(zeros != (zeros <- sum(x == 0)) && any(x == 0) &&
+          iter < maxit) {
         x[x > 0] <- x[x > 0] - min(x[x > 0]) + 1
         x[x == 0] <- beals(x)[x == 0]
+        iter <- iter + 1
     }
     x
 }

Modified: pkg/vegan/inst/ChangeLog
===================================================================
--- pkg/vegan/inst/ChangeLog	2011-07-16 12:26:47 UTC (rev 1681)
+++ pkg/vegan/inst/ChangeLog	2011-07-17 06:25:09 UTC (rev 1682)
@@ -4,6 +4,13 @@
 
 Version 1.90-1 (opened July 3, 2011)
 
+	* swan: gained argument 'maxit' that can be used to restrict the
+	number of beals() passes on zeros. The default is 'maxit = Inf'
+	which is the old behaviour: beals() passes on zero entries
+	continue until there are no zeros or the number of zeros does not
+	change. Probably only 'maxit = 1' makes any sense (in addition to
+	the default 'maxit = Inf'), but all values are allowed.
+
 	* metaMDSrotate: results could be a bit off with NA in
 	environmental vector and >2D solution. The starting scores must be
 	orthogonal, but the initial orthogonalizing PCA was run without

Modified: pkg/vegan/man/beals.Rd
===================================================================
--- pkg/vegan/man/beals.Rd	2011-07-16 12:26:47 UTC (rev 1681)
+++ pkg/vegan/man/beals.Rd	2011-07-17 06:25:09 UTC (rev 1682)
@@ -14,7 +14,7 @@
 }
 \usage{
 beals(x, species = NA, reference = x, type = 0, include = TRUE)
-swan(x)
+swan(x, maxit = Inf)
 }
 \arguments{
   \item{x}{Community data frame or matrix. }
@@ -29,8 +29,14 @@
   included when computing the mean of the conditioned probabilities. The
   original Beals (1984) definition is equivalent to \code{include=TRUE},
   while the formulation of \enc{Münzbergová}{Munzbergova} and Herben is
-  equal to \code{include=FALSE}. }  
+  equal to \code{include=FALSE}.}
+
+  \item{maxit}{Maximum number of iterations. The default \code{Inf}
+    means that iterations are continued until there are no zeros or
+    the number of zeros does not change. Probably only 
+    \code{maxit = 1} makes sense in addition to the default.}  
 }
+
 \details{
 
   Beals smoothing is the estimated probability \eqn{p_{ij}}{p[ij]} that



More information about the Vegan-commits mailing list