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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Tue Jun 1 10:22:36 CEST 2010


Author: jarioksa
Date: 2010-06-01 10:22:35 +0200 (Tue, 01 Jun 2010)
New Revision: 1210

Modified:
   pkg/vegan/R/tsallis.R
Log:
marginal (<10 %) speed-up

Modified: pkg/vegan/R/tsallis.R
===================================================================
--- pkg/vegan/R/tsallis.R	2010-06-01 07:05:25 UTC (rev 1209)
+++ pkg/vegan/R/tsallis.R	2010-06-01 08:22:35 UTC (rev 1210)
@@ -21,10 +21,10 @@
         }
         else {
             if (scales[a] == 1) result[, a] <- diversity(x, "shannon")
-            if (scales[a] == 0) result[, a] <- apply(x > 0, 1, function(y) sum(y) - 1)
+            if (scales[a] == 0) result[, a] <- rowSums(x > 0) - 1
         }
         if (norm) {
-            ST <- apply(x > 0, 1, sum)
+            ST <- rowSums(x > 0)
             if (scales[a] == 1) result[, a] <- result[, a] / log(ST)
             else result[, a] <- result[, a] / ((ST^(1-scales[a]) - 1) / (1 - scales[a]))
         }



More information about the Vegan-commits mailing list