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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Mon Jan 17 16:49:44 CET 2011


Author: jarioksa
Date: 2011-01-17 16:49:44 +0100 (Mon, 17 Jan 2011)
New Revision: 1461

Modified:
   pkg/vegan/R/anova.ccabyterm.R
   pkg/vegan/R/ordiParseFormula.R
   pkg/vegan/inst/ChangeLog
Log:
anova.cca works with attach()ed data.frame instead of data=

Modified: pkg/vegan/R/anova.ccabyterm.R
===================================================================
--- pkg/vegan/R/anova.ccabyterm.R	2011-01-17 12:18:46 UTC (rev 1460)
+++ pkg/vegan/R/anova.ccabyterm.R	2011-01-17 15:49:44 UTC (rev 1461)
@@ -25,14 +25,18 @@
     pchi[ntrm, ] <- sim$num
     df[ntrm:(ntrm + 1)] <- sim$df
     chi[ntrm:(ntrm + 1)] <- sim$chi
-    modelframe <- ordiGetData(object$call, NULL)
+    if (!is.null(object$call$data))
+        modelframe <- ordiGetData(object$call, NULL)
+    else
+        modelframe <- NULL
     environment(object$terms) <- environment()
     for (.ITRM in ntrm:2) {
         if (ntrm < 2) 
             break
         assign(".Random.seed", sim$Random.seed, envir = .GlobalEnv)
         fla <- as.formula(paste(" . ~ . -", trmlab[.ITRM]))
-        object <- update(object, fla, data = modelframe)
+        object <- update(object, fla,
+                         if (!is.null(modelframe)) data = modelframe)
         ## Change in data set due to missing values?
         if (length(object$residuals) != n0)
             stop("number of rows has changed: remove missing values?")

Modified: pkg/vegan/R/ordiParseFormula.R
===================================================================
--- pkg/vegan/R/ordiParseFormula.R	2011-01-17 12:18:46 UTC (rev 1460)
+++ pkg/vegan/R/ordiParseFormula.R	2011-01-17 15:49:44 UTC (rev 1461)
@@ -48,7 +48,8 @@
     ## Select a subset of data and species
     if (!is.null(subset)) {
         subset <- eval(subset,
-                       if (inherits(data, "data.frame")) cbind(data, X) else X,
+                       if (inherits(data, "data.frame")) cbind(data, X)
+                       else as.data.frame(X),
                        parent.frame())
         X <- X[subset, , drop = FALSE]
         if (NROW(mf) > 0)

Modified: pkg/vegan/inst/ChangeLog
===================================================================
--- pkg/vegan/inst/ChangeLog	2011-01-17 12:18:46 UTC (rev 1460)
+++ pkg/vegan/inst/ChangeLog	2011-01-17 15:49:44 UTC (rev 1461)
@@ -34,6 +34,10 @@
 	anova.cca bug in vegan-forge). It seems that subset and na.action
 	also work. 
 
+	* anova.cca: most cases work now when terms are given in
+	attach()ed data frame after changes to anova.ccabyterm() and
+	ordiParseFormula(). 
+
 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