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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Tue Sep 1 17:50:53 CEST 2009


Author: jarioksa
Date: 2009-09-01 17:50:53 +0200 (Tue, 01 Sep 2009)
New Revision: 975

Modified:
   pkg/vegan/R/cca.formula.R
   pkg/vegan/R/rda.formula.R
   pkg/vegan/inst/ChangeLog
   pkg/vegan/man/cca.Rd
   pkg/vegan/man/cca.object.Rd
   pkg/vegan/man/vegan-internal.Rd
Log:
cca & rda can handle missing values in constraints and conditions

Modified: pkg/vegan/R/cca.formula.R
===================================================================
--- pkg/vegan/R/cca.formula.R	2009-09-01 15:49:30 UTC (rev 974)
+++ pkg/vegan/R/cca.formula.R	2009-09-01 15:50:53 UTC (rev 975)
@@ -1,12 +1,12 @@
-"cca.formula" <-
-function (formula, data, ...) 
+`cca.formula` <-
+    function (formula, data, na.action = na.fail, ...) 
 {
     if (missing(data)) {
         data <- parent.frame()
     } else {
         data <- ordiGetData(match.call(), environment(formula))
     }
-    d <- ordiParseFormula(formula, data)
+    d <- ordiParseFormula(formula, data, na.action = na.action)
     sol <- cca.default(d$X, d$Y, d$Z)
     if (!is.null(sol$CCA)) 
         sol$CCA$centroids <- centroids.cca(sol$CCA$wa, d$modelframe, 
@@ -20,8 +20,11 @@
     }
     sol$terms <- d$terms
     sol$terminfo <- ordiTerminfo(d, data)
+    sol$na.action <- d$na.action
     sol$call <- match.call()
     sol$call[[1]] <- as.name("cca")
     sol$call$formula <- formula(d$terms, width.cutoff = 500)
+    if (!is.null(sol$na.action) && inherits(sol$na.action, "exclude"))
+        sol <- ordiNAexclude(sol, d$excluded)
     sol
 }

Modified: pkg/vegan/R/rda.formula.R
===================================================================
--- pkg/vegan/R/rda.formula.R	2009-09-01 15:49:30 UTC (rev 974)
+++ pkg/vegan/R/rda.formula.R	2009-09-01 15:50:53 UTC (rev 975)
@@ -1,12 +1,12 @@
 "rda.formula" <-
-function (formula, data, scale = FALSE, ...) 
+function (formula, data, scale = FALSE, na.action = na.fail, ...) 
 {
     if (missing(data)) {
         data <- parent.frame()
     } else {
         data <- ordiGetData(match.call(), environment(formula))
     }
-    d <- ordiParseFormula(formula, data)
+    d <- ordiParseFormula(formula, data, na.action = na.action)
     sol <- rda.default(d$X, d$Y, d$Z, scale)
     if (!is.null(sol$CCA)) 
         sol$CCA$centroids <- centroids.cca(sol$CCA$wa, d$modelframe)
@@ -19,8 +19,11 @@
     }
     sol$terms <- d$terms
     sol$terminfo <- ordiTerminfo(d, data)
+    sol$na.action <- d$na.action
     sol$call <- match.call()
     sol$call[[1]] <- as.name("rda")
     sol$call$formula <- formula(d$terms, width.cutoff = 500)
+    if (!is.null(sol$na.action) && inherits(sol$na.action, "exclude"))
+        sol <- ordiNAexclude(sol, d$excluded)
     sol
 }

Modified: pkg/vegan/inst/ChangeLog
===================================================================
--- pkg/vegan/inst/ChangeLog	2009-09-01 15:49:30 UTC (rev 974)
+++ pkg/vegan/inst/ChangeLog	2009-09-01 15:50:53 UTC (rev 975)
@@ -4,6 +4,16 @@
 
 Version 1.16-26 (opened August 31,2009)
 
+	* cca and rda: can now handle missing values in constraints or
+	conditions. With 'na.action = na.omit', the rows with missing
+	values are removed, and with 'na.action = na.exclude' all rows are
+	retained but results that cannot be computed are NA. The LC scores
+	cannot be computed with missing values, but WA scores (usually)
+	can be computed. The results with 'na.exclude' probably fail with
+	most support functions because these do not expect missing values
+	in the results. These functions are fixed with time. capscale does
+	not (yet) handle missing data.
+
 	* oecosimu: does not depend on permatfull/permatswap, but method
 	can be a function. The r2dtable method implemented also
 	to be used with adipart and related functions.
@@ -18,12 +28,9 @@
 	omitted. In constrained ordination, LC scores will NA, but WA
 	scores are found from the community data, and the current function
 	uses predict.cca/predict.rda with 'newdata' of removed
-	observations to estimate WA scores of excluded observation. The
-	calling functions won't use this yet (working...).
+	observations to estimate WA scores of excluded observation.
 	
-	* ordiParseFormula: handles missing values with na.action. The
-	calling functions (cca, rda, capscale) won't use this
-	yet (working...).
+	* ordiParseFormula: handles missing values with na.action. 
 
 Version 1.16-25 (closed August 31, 2009)
 

Modified: pkg/vegan/man/cca.Rd
===================================================================
--- pkg/vegan/man/cca.Rd	2009-09-01 15:49:30 UTC (rev 974)
+++ pkg/vegan/man/cca.Rd	2009-09-01 15:50:53 UTC (rev 975)
@@ -19,9 +19,9 @@
   These are all very popular ordination techniques in community ecology.
 }
 \usage{
-\method{cca}{formula}(formula, data, ...)
+\method{cca}{formula}(formula, data, na.action = na.fail, ...)
 \method{cca}{default}(X, Y, Z, ...)
-\method{rda}{formula}(formula, data, scale=FALSE, ...)
+\method{rda}{formula}(formula, data, scale=FALSE, na.action = na.fail, ...)
 \method{rda}{default}(X, Y, Z, scale=FALSE, ...)
 }
 
@@ -38,6 +38,14 @@
   \item{Z}{ Conditioning matrix, the effect of which is removed
     (`partialled out') before next step. Can be missing.}
   \item{scale}{Scale species to unit variance (like correlations).}
+  \item{na.action}{Handling of missing values in constraints or
+    conditions. The default (\code{\link{na.fail}}) is to stop with
+    missing value. Choice \code{\link{na.omit}} removes all rows with
+    missing values. Choice \code{\link{na.exclude}} keeps all
+    observations but gives \code{NA} for results that cannot be
+    calculated. The WA scores of rows may be found also for missing
+    values in constraints. Missing values are never allowed in
+    dependent community data. }
   \item{...}{Other arguments for \code{print} or \code{plot} functions
     (ignored in other functions).}
 }

Modified: pkg/vegan/man/cca.object.Rd
===================================================================
--- pkg/vegan/man/cca.object.Rd	2009-09-01 15:49:30 UTC (rev 974)
+++ pkg/vegan/man/cca.object.Rd	2009-09-01 15:50:53 UTC (rev 975)
@@ -36,7 +36,13 @@
     \code{\link{predict.cca}} with \code{newdata}.  This is missing if
     the ordination was not called with \code{formula}.}
   \item{tot.chi}{Total inertia or the sum of all eigenvalues.}
-  \item{pCCA, CCA, CA}{Actual ordination results for conditioned
+  \item{na.action}{The result of \code{\link{na.action}} if missing
+    values in constraints were handled by \code{\link{na.omit}} or
+    \code{\link{na.exclude}} (or \code{NULL} if there were no missing
+    values). This is a vector of indices of missing value rows in the
+    original data and a class of the action, usually either
+    \code{"omit"} or \code{"exclude"}.}
+\item{pCCA, CCA, CA}{Actual ordination results for conditioned
     (partial), constrained and unconstrained components of the
     model. Any of these can be \code{NULL} if there is no corresponding
     component.

Modified: pkg/vegan/man/vegan-internal.Rd
===================================================================
--- pkg/vegan/man/vegan-internal.Rd	2009-09-01 15:49:30 UTC (rev 974)
+++ pkg/vegan/man/vegan-internal.Rd	2009-09-01 15:50:53 UTC (rev 975)
@@ -18,7 +18,7 @@
 ordiGetData(call, env)
 ordiParseFormula(formula, data, xlev = NULL, envdepth = 2, na.action = na.fail)
 ordiTerminfo(d, data)
-ordiNAexclude(object, exluded)
+ordiNAexclude(object, excluded)
 ordiArrowMul(x, at = c(0,0), fill = 0.75)
 ordiArgAbsorber(..., shrink, origin, scaling, triangular,
                 display, choices, const, FUN)



More information about the Vegan-commits mailing list