[Vegan-commits] r625 - pkg/vegan/R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Mon Dec 8 10:06:08 CET 2008


Author: jarioksa
Date: 2008-12-08 10:06:07 +0100 (Mon, 08 Dec 2008)
New Revision: 625

Modified:
   pkg/vegan/R/permatswap.R
Log:
a lot of speed-up (30%) in permatswap: use colSums() rowSums() instead of apply()

Modified: pkg/vegan/R/permatswap.R
===================================================================
--- pkg/vegan/R/permatswap.R	2008-12-08 06:35:14 UTC (rev 624)
+++ pkg/vegan/R/permatswap.R	2008-12-08 09:06:07 UTC (rev 625)
@@ -60,7 +60,7 @@
             for (i in 1:times) {
                 if (count) {
                     ms <- sum(m[id,] > 0)
-                    tmp <- r2dtable(1, apply(m[id,], 1, sum), apply(m[id,], 2, sum))[[1]]
+                    tmp <- r2dtable(1, rowSums(m[id,]), colSums(m[id,]))[[1]]
                     ## if fills are equal, no need to do it quasiswap
                     if (sum(tmp > 0) != ms) {
                         tmp <- .C("rswapcount",



More information about the Vegan-commits mailing list