[Vegan-commits] r1630 - pkg/vegan/R
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Mon Jun 13 20:24:30 CEST 2011
Author: jarioksa
Date: 2011-06-13 20:24:30 +0200 (Mon, 13 Jun 2011)
New Revision: 1630
Modified:
pkg/vegan/R/anova.prc.R
Log:
anova.prc() uses original model data and formula instead of interal names and structures, and passes rda() arguments
Modified: pkg/vegan/R/anova.prc.R
===================================================================
--- pkg/vegan/R/anova.prc.R 2011-06-12 19:44:40 UTC (rev 1629)
+++ pkg/vegan/R/anova.prc.R 2011-06-13 18:24:30 UTC (rev 1630)
@@ -1,12 +1,24 @@
`anova.prc` <-
function(object, ...)
{
- ## Refit prc() as an rda() for anova.cca()
- Z <- qr.X(object$pCCA$QR)
- X <- qr.X(object$CCA$QR)
- ## Get the name of the original response variable
- fla <- as.character(object$call$response)
- fla <- as.formula(paste(fla, "~ X + Condition(Z)"))
- mod <- rda(fla)
- anova(mod, ...)
+ ## if user specified 'by', cast prc() to an rda() and call anova
+ ## on its result
+ extras <- match.call(expand.dots = FALSE)
+ if ("by" %in% names(extras$...)) {
+ Y <- as.character(object$call$response)
+ X <- as.character(object$call$treatment)
+ Z <- as.character(object$call$time)
+ fla <- paste(Y, "~", X, "*", Z, "+ Condition(", Z, ")")
+ fla <- as.formula(fla)
+ ## get extras
+ m <- match(c("data", "scale", "subset", "na.action"),
+ names(object$call), 0)
+ call <- object$call[c(1,m)]
+ call$formula <- fla
+ call[[1]] <- as.name("rda.formula")
+ object <- eval(call, parent.frame())
+ anova(object, ...)
+ } else {
+ NextMethod("anova", object, ...)
+ }
}
More information about the Vegan-commits
mailing list