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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sun Jan 16 19:05:58 CET 2011


Author: jarioksa
Date: 2011-01-16 19:05:58 +0100 (Sun, 16 Jan 2011)
New Revision: 1457

Modified:
   pkg/vegan/R/capscale.R
   pkg/vegan/inst/ChangeLog
   pkg/vegan/man/capscale.Rd
Log:
implemented 'subset='

Modified: pkg/vegan/R/capscale.R
===================================================================
--- pkg/vegan/R/capscale.R	2011-01-14 19:56:17 UTC (rev 1456)
+++ pkg/vegan/R/capscale.R	2011-01-16 18:05:58 UTC (rev 1457)
@@ -1,7 +1,7 @@
 `capscale` <-
     function (formula, data, distance = "euclidean", sqrt.dist = FALSE,
               comm = NULL, add = FALSE, dfun = vegdist,
-              metaMDSdist = FALSE, na.action = na.fail, ...) 
+              metaMDSdist = FALSE, na.action = na.fail, subset = NULL, ...) 
 {
     EPS <- sqrt(.Machine$double.eps)
     if (!inherits(formula, "formula")) 
@@ -44,7 +44,13 @@
     ## deleted due to missing values)
     fla <- update(formula, X ~ .)
     environment(fla) <- environment()
-    d <- ordiParseFormula(fla, data, envdepth = 1, na.action = na.action)
+    d <- ordiParseFormula(fla, cbind(data, comm), envdepth = 1,
+                          na.action = na.action,
+                          subset = substitute(subset))
+    ## ordiParseFormula subsets rows of dissimilarities: do the same
+    ## for columns
+    if (!is.null(d$subset))
+        d$X <- d$X[, d$subset, drop = FALSE]
     ## Delete columns if rows were deleted due to missing values
     if (!is.null(d$na.action)) {
         d$X <- d$X[, -d$na.action, drop = FALSE]
@@ -101,6 +107,9 @@
     }
     if (!is.null(comm)) {
         comm <- scale(comm, center = TRUE, scale = FALSE)
+        ## take a 'subset' of the community after scale()
+        if (!is.null(d$subset))
+            comm <- comm[d$subset, , drop = FALSE]
         sol$colsum <- sd(comm)
         if (!is.null(sol$pCCA)) 
             comm <- qr.resid(sol$pCCA$QR, comm)
@@ -137,6 +146,7 @@
     sol$inertia <- inertia
     if (metaMDSdist)
         sol$metaMDSdist <- commname
+    sol$subset <- d$subset
     sol$na.action <- d$na.action
     class(sol) <- c("capscale", class(sol))
     if (!is.null(sol$na.action))

Modified: pkg/vegan/inst/ChangeLog
===================================================================
--- pkg/vegan/inst/ChangeLog	2011-01-14 19:56:17 UTC (rev 1456)
+++ pkg/vegan/inst/ChangeLog	2011-01-16 18:05:58 UTC (rev 1457)
@@ -28,6 +28,13 @@
 	* cca/rda: added item 'subset' that is the subset argument
 	evaluated to a logical vector.
 
+	* capscale: implemented 'subset' (and this also works with
+	anova.cca). Still need to check in which order we have stepacross,
+	standardization, na.action etc and subset. However, currently it
+	looks like all anova.cca tests pass also with capscale (but more
+	thorough test will be run before closeing the anova.cca bug in
+	vegan-forge) 
+
 Version 1.18-20 (closed January 9, 2011)
 
 	* base of vegan release 1.17-6 (released on Jan 10, 2011).

Modified: pkg/vegan/man/capscale.Rd
===================================================================
--- pkg/vegan/man/capscale.Rd	2011-01-14 19:56:17 UTC (rev 1456)
+++ pkg/vegan/man/capscale.Rd	2011-01-16 18:05:58 UTC (rev 1457)
@@ -79,6 +79,11 @@
      \code{NA} for scores of missing observations. Unlike in
      \code{\link{rda}}, no WA scores are available for missing
      constraints or conditions.}
+   \item{subset}{Subset of data rows. This can be a logical vector
+     which is \code{TRUE} for kept observations, or a logical
+     expression which can contain variables in the working
+     environment, \code{data} or species names of the community data
+     (if given in the formula or as \code{comm} argument).}
    \item{\dots}{Other parameters passed to \code{\link{rda}} or to
      \code{\link{metaMDSdist}}.  }
 }



More information about the Vegan-commits mailing list