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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sun Oct 25 08:26:23 CET 2009


Author: jarioksa
Date: 2009-10-25 08:26:16 +0100 (Sun, 25 Oct 2009)
New Revision: 1052

Modified:
   pkg/vegan/R/decostand.R
   pkg/vegan/inst/ChangeLog
   pkg/vegan/man/decostand.Rd
Log:
decostand: added Marti Anderson's log scaling as a part of Feature Request #473

Modified: pkg/vegan/R/decostand.R
===================================================================
--- pkg/vegan/R/decostand.R	2009-10-24 11:07:37 UTC (rev 1051)
+++ pkg/vegan/R/decostand.R	2009-10-25 07:26:16 UTC (rev 1052)
@@ -1,10 +1,10 @@
 "decostand" <-
-    function (x, method, MARGIN, range.global, na.rm = FALSE, ...) 
+    function (x, method, MARGIN, range.global, logbase = 2, na.rm = FALSE, ...) 
 {
     wasDataFrame <- is.data.frame(x)
     x <- as.matrix(x)
     METHODS <- c("total", "max", "frequency", "normalize", "range", 
-                 "standardize", "pa", "chi.square", "hellinger")
+                 "standardize", "pa", "chi.square", "hellinger", "log")
     method <- match.arg(method, METHODS)
     if (any(x < 0, na.rm = na.rm)) {
         k <- min(x, na.rm = na.rm)
@@ -65,6 +65,13 @@
                          na.rm = na.rm)), sqrt(colSums(x, na.rm = na.rm)))
     }, hellinger = {
         x <- sqrt(decostand(x, "total", MARGIN = MARGIN, na.rm = na.rm))
+      }, log = {### Marti Anderson logs, after Etienne Laliberte
+        if (!isTRUE(all.equal(as.integer(x), as.vector(x)))) {
+            x <- x / min(x[x > 0], na.rm = TRUE)
+            warning("non-integer data: divided by smallest positive value",
+                    call. = FALSE)
+        }
+        x[x > 0 & !is.na(x)] <- log(x[x > 0 & !is.na(x)], base = logbase) + 1
     })
     if (any(is.nan(x))) 
         warning("result contains NaN, perhaps due to impossible mathematical operation\n")

Modified: pkg/vegan/inst/ChangeLog
===================================================================
--- pkg/vegan/inst/ChangeLog	2009-10-24 11:07:37 UTC (rev 1051)
+++ pkg/vegan/inst/ChangeLog	2009-10-25 07:26:16 UTC (rev 1052)
@@ -4,11 +4,19 @@
 
 Version 1.16-32 (opened October 24, 2009)
 
+	* decostand: implemented Marti Anderson's log scaling of type
+	log(x, base = logbase) + 1 as a part of Feature Request #473. The
+	coding follows closely Etienne Laliberte's suggestion, and also
+	handles non-negative non-integer data. 
+
 	* vegdist: C code for an alternative version of Gower Index that
 	skips double zeros. No R level interface yet. If this function is
 	to be used from vegdist.R, it should be added as item 14 in
 	'method' list, and the R level preprocessing should be done
-	similarly as for "gower" (method choice 6).
+	similarly as for "gower" (method choice 6). This was implemented
+	for inspecting the implementation of second part of Feature
+	Request #473, but may be removed if that part of the request is
+	not implemented.
 	
 Version 1.16-31 (closed October 24, 2009)
 

Modified: pkg/vegan/man/decostand.Rd
===================================================================
--- pkg/vegan/man/decostand.Rd	2009-10-24 11:07:37 UTC (rev 1051)
+++ pkg/vegan/man/decostand.Rd	2009-10-25 07:26:16 UTC (rev 1052)
@@ -8,7 +8,7 @@
 methods for community ecologists.
 }
 \usage{
-decostand(x, method, MARGIN, range.global, na.rm=FALSE, ...)
+decostand(x, method, MARGIN, range.global, logbase = 2, na.rm=FALSE, ...)
 
 wisconsin(x)
 }
@@ -22,6 +22,7 @@
     \code{method = "range"}.  This allows using same ranges across
     subsets of data.  The dimensions of \code{MARGIN} must match with
     \code{x}. }
+  \item{logbase}{The logarithm base used in \code{method = "log"}.}
   \item{na.rm}{Ignore missing values in row or column standardizations.}
   \item{\dots}{Other arguments to the function (ignored).}
 }
@@ -52,6 +53,14 @@
       1}).
     \item \code{hellinger}: square root of \code{method = "total"}
     (Legendre & Gallagher 2001).
+    \item \code{log}: logarithmic transformation as suggested by Anderson 
+     et al. (2006): \eqn{log_b (x) + 1} for \eqn{x > 0},  where \eqn{b} is 
+     the base of the logarithm. Zeros are left as zeros. Higher bases give
+     less weight to quantities and more to presences, and \code{logbase = Inf}
+     gives the presence/absence scaling. Please note this is not \eqn{log(x+1)}.
+     Anderson et al. (2006) suggested this for their (strongly) modified
+     Gower distance, but the standardization can be used independently
+     of distance indices.
   }
   Standardization, as contrasted to transformation, means that the
   entries are transformed relative to other entries.
@@ -76,10 +85,15 @@
   \code{"decostand"} giving the name of applied standardization
   \code{"method"}.
 }
-\author{Jari Oksanen}
+\author{Jari Oksanen and Etienne Laliberte (\code{method = "log"}).}
 \note{Common transformations can be made with standard \R functions.}
 
-\references{
+\references{ 
+  
+  Anderson, M.J., Ellingsen, K.E. & McArdle, B.H. (2006) Multivariate
+  dispersion as a measure of beta diversity. \emph{Ecology Letters} 
+  \strong{9}, 683-693.
+
   Legendre, P. & Gallagher, E.D. (2001) Ecologically meaningful
   transformations for ordination of species data. \emph{Oecologia}
   \strong{129}; 271--280.



More information about the Vegan-commits mailing list