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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Tue Mar 2 19:16:37 CET 2010


Author: jarioksa
Date: 2010-03-02 19:16:37 +0100 (Tue, 02 Mar 2010)
New Revision: 1158

Modified:
   pkg/vegan/R/nesteddisc.R
   pkg/vegan/inst/ChangeLog
Log:
nesteddisc failed if highest species frequencies had tied values

Modified: pkg/vegan/R/nesteddisc.R
===================================================================
--- pkg/vegan/R/nesteddisc.R	2010-02-28 16:06:58 UTC (rev 1157)
+++ pkg/vegan/R/nesteddisc.R	2010-03-02 18:16:37 UTC (rev 1158)
@@ -22,7 +22,7 @@
     comm <- comm[, k]
     ## run lengths: numbers of tied values
     le <- rle(cs)$lengths
-    cle <- cumsum(le)
+    cle <- c(0, cumsum(le))
     x <- seq(along=cs)
     ## Range of row sums: only swaps between these have an effect
     rs <- range(rowSums(comm))
@@ -32,19 +32,19 @@
     for (i in 1:length(le)) {
         if (le[i] > 1) {
             take <- x
-            idx <- (1:le[i]) + if(i == 1) 0 else  cle[i-1]
+            idx <- (1:le[i]) + cle[i]
             ## Can swaps influence discrepancy?
             if (idx[1] > rs[2] || idx[le[i]] < rs[1])
                 next
             Ad <- FUN(x)
             if (le[i] <= NALL)
-                perm <- matrix(allPerms(le[i]), ncol=le[i]) + cle[i-1]
+                perm <- matrix(allPerms(le[i]), ncol=le[i]) + cle[i]
             else {
                 ties <- TRUE
                 perm <- matrix(0, nrow=NITER, ncol=le[i])
                 for (j in 1:NITER)
                     perm[j,] <- permuted.index2(le[i])
-                perm <- perm + if(i==1) 0 else  cle[i-1]
+                perm <- perm + cle[i]
             }
             for (j in 1:nrow(perm)) {
                 take[idx] <- perm[j,]

Modified: pkg/vegan/inst/ChangeLog
===================================================================
--- pkg/vegan/inst/ChangeLog	2010-02-28 16:06:58 UTC (rev 1157)
+++ pkg/vegan/inst/ChangeLog	2010-03-02 18:16:37 UTC (rev 1158)
@@ -4,6 +4,11 @@
 
 Version 1.18-2 (opened February 18, 2010)
 
+	* nesteddisc: failed if highest species frequencies were tied. The
+	error message was "Error: dims [prodcut 15] do not match the
+	length of object [0]". Found by Eric Fuchs in the help forum of
+	vegan.r-forge.r-project.org. 
+
 	* screeplot: New argument 'legend' for all methods (except
 	'decorana') to draw a legend if the observed and broken stick
 	distribution are both plotted. Now also respects 'pch' for the



More information about the Vegan-commits mailing list