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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Thu Dec 4 06:35:37 CET 2008


Author: psolymos
Date: 2008-12-04 06:35:37 +0100 (Thu, 04 Dec 2008)
New Revision: 607

Modified:
   pkg/vegan/R/adipart.R
Log:
proportional weighting corrected


Modified: pkg/vegan/R/adipart.R
===================================================================
--- pkg/vegan/R/adipart.R	2008-12-04 05:03:52 UTC (rev 606)
+++ pkg/vegan/R/adipart.R	2008-12-04 05:35:37 UTC (rev 607)
@@ -50,8 +50,8 @@
         ## weights will change in oecosimu thus need to be recalculated
         if (weights == "prop")
             wt <- lapply(1:nl, function(i) apply(tmp[[i]], 1, function(z) sum(z) / sum(matr)))
-            else wt <- lapply(1:nl, function(i) rep(1, NROW(tmp[[i]])))
-        a <- sapply(1:nl, function(i) mean(divfun(tmp[[i]]) * wt[[i]]))
+            else wt <- lapply(1:nl, function(i) rep(1 / NROW(tmp[[i]]), NROW(tmp[[i]])))
+        a <- sapply(1:nl, function(i) sum(divfun(tmp[[i]]) * wt[[i]]))
         names(a) <- c(paste("alpha", 1:(nl-1), sep="."), "gamma")
         b <- sapply(2:nl, function(i) a[i] - a[(i-1)])
         names(b) <- paste("beta", 1:(nl-1), sep=".")



More information about the Vegan-commits mailing list