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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Tue Jan 18 18:07:39 CET 2011


Author: jarioksa
Date: 2011-01-18 18:07:39 +0100 (Tue, 18 Jan 2011)
New Revision: 1462

Modified:
   pkg/vegan/R/anova.ccabyaxis.R
   pkg/vegan/R/anova.ccabyterm.R
   pkg/vegan/R/ordiParseFormula.R
   pkg/vegan/inst/ChangeLog
Log:
anova.cca tests (mostly) work with NA data

Modified: pkg/vegan/R/anova.ccabyaxis.R
===================================================================
--- pkg/vegan/R/anova.ccabyaxis.R	2011-01-17 15:49:44 UTC (rev 1461)
+++ pkg/vegan/R/anova.ccabyaxis.R	2011-01-18 17:07:39 UTC (rev 1462)
@@ -7,21 +7,21 @@
         stop("Needs a constrained ordination")
     if (is.null(object$terms)) 
         stop("Analysis is only possible for models fitted using formula")
+    ## Handle missing values in scores, both "omit" and "exclude" to
+    ## match dims with data.
+    if (!is.null(object$na.action)) {
+        u <- stats:::napredict.exclude(object$na.action, object$CCA$u)
+    } else {
+        u <- object$CCA$u
+    }
     ## pad with NA rows if there is a subset
     if (!is.null(object$subset)) {
         lc <- matrix(NA, nrow=length(object$subset),
-                     ncol = ncol(object$CCA$u))
-        lc[object$subset,]  <- object$CCA$u
+                     ncol = ncol(u))
+        lc[object$subset,]  <- u
         object$call$subset <- object$subset
-    } else {
-        lc <- object$CCA$u
     }
     lc <- as.data.frame(lc)
-    ## Handle missing values in scores, both "omit" and "exclude" to
-    ## match dims with data.
-    if (!is.null(object$na.action)) {
-        lc <- stats:::napredict.exclude(object$na.action, lc)
-    }
     axnam <- colnames(lc)
     df <- c(rep(1, rnk), object$CA$rank)
     chi <- c(object$CCA$eig, Residual = object$CA$tot.chi)

Modified: pkg/vegan/R/anova.ccabyterm.R
===================================================================
--- pkg/vegan/R/anova.ccabyterm.R	2011-01-17 15:49:44 UTC (rev 1461)
+++ pkg/vegan/R/anova.ccabyterm.R	2011-01-18 17:07:39 UTC (rev 1462)
@@ -29,7 +29,6 @@
         modelframe <- ordiGetData(object$call, NULL)
     else
         modelframe <- NULL
-    environment(object$terms) <- environment()
     for (.ITRM in ntrm:2) {
         if (ntrm < 2) 
             break

Modified: pkg/vegan/R/ordiParseFormula.R
===================================================================
--- pkg/vegan/R/ordiParseFormula.R	2011-01-17 15:49:44 UTC (rev 1461)
+++ pkg/vegan/R/ordiParseFormula.R	2011-01-18 17:07:39 UTC (rev 1462)
@@ -50,7 +50,7 @@
         subset <- eval(subset,
                        if (inherits(data, "data.frame")) cbind(data, X)
                        else as.data.frame(X),
-                       parent.frame())
+                       parent.frame(2))
         X <- X[subset, , drop = FALSE]
         if (NROW(mf) > 0)
             mf <- mf[subset, , drop = FALSE]

Modified: pkg/vegan/inst/ChangeLog
===================================================================
--- pkg/vegan/inst/ChangeLog	2011-01-17 15:49:44 UTC (rev 1461)
+++ pkg/vegan/inst/ChangeLog	2011-01-18 17:07:39 UTC (rev 1462)
@@ -38,6 +38,12 @@
 	attach()ed data frame after changes to anova.ccabyterm() and
 	ordiParseFormula(). 
 
+	* anova.cca: works (mostly) when there are missing values. The
+	exception found was 'by = "term"' when the data frame is not given
+	as a 'data=' argument, but as an attached data.frame. In this case
+	'by = "term"' detects a change in the number of rows and stops
+	with a message.
+
 Version 1.18-20 (closed January 9, 2011)
 
 	* base of vegan release 1.17-6 (released on Jan 10, 2011).



More information about the Vegan-commits mailing list