[Vegan-commits] r815 - in pkg/vegan: R inst
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Mon Apr 27 09:46:41 CEST 2009
Author: jarioksa
Date: 2009-04-27 09:46:39 +0200 (Mon, 27 Apr 2009)
New Revision: 815
Modified:
pkg/vegan/R/anova.ccabyaxis.R
pkg/vegan/R/anova.ccabymargin.R
pkg/vegan/R/anova.ccabyterm.R
pkg/vegan/inst/ChangeLog
Log:
anova.cca(..., by = ) name clash if data were indexed with 'i' in fitted model
Modified: pkg/vegan/R/anova.ccabyaxis.R
===================================================================
--- pkg/vegan/R/anova.ccabyaxis.R 2009-04-27 07:19:23 UTC (rev 814)
+++ pkg/vegan/R/anova.ccabyaxis.R 2009-04-27 07:46:39 UTC (rev 815)
@@ -26,20 +26,20 @@
bigperm <- out$N.Perm[1]
environment(object$terms) <- environment()
if (rnk > 1) {
- for (i in 2:rnk) {
- zz <- paste(paste("Condition(", axnam[1:(i - 1)],
+ for (.ITRM in 2:rnk) {
+ zz <- paste(paste("Condition(", axnam[1:(.ITRM - 1)],
")"), collapse = "+")
fla <- update(formula(object), paste(". ~ . +", zz))
sol <- update(object, fla, data = newdata)
assign(".Random.seed", seed, envir = .GlobalEnv)
- out[i, ] <- as.matrix(anova(sol, first = TRUE, ...))[1,
+ out[.ITRM, ] <- as.matrix(anova(sol, first = TRUE, ...))[1,
]
- if (out[i, "N.Perm"] > bigperm) {
- bigperm <- out[i, "N.Perm"]
+ if (out[.ITRM, "N.Perm"] > bigperm) {
+ bigperm <- out[.ITRM, "N.Perm"]
bigseed <- get(".Random.seed", envir = .GlobalEnv,
inherits = FALSE)
}
- if (out[i, "Pr(>F)"] > cutoff)
+ if (out[.ITRM, "Pr(>F)"] > cutoff)
break
}
}
Modified: pkg/vegan/R/anova.ccabymargin.R
===================================================================
--- pkg/vegan/R/anova.ccabymargin.R 2009-04-27 07:19:23 UTC (rev 814)
+++ pkg/vegan/R/anova.ccabymargin.R 2009-04-27 07:46:39 UTC (rev 815)
@@ -10,12 +10,12 @@
trms <- trms[keep]
ntrms <- length(trms)
bigperm <- 0
- for (i in 1:ntrms) {
+ for (.ITRM in 1:ntrms) {
fla <- formula(object)
## Put all trms except current into Condition() and update
## formula
if (length(alltrms) > 1) {
- keeptrms <- alltrms[!(alltrms==trms[i])]
+ keeptrms <- alltrms[!(alltrms==trms[.ITRM])]
updfla <- paste("Condition(",paste(keeptrms, collapse="+"), ")")
fla <- update(fla, paste(". ~ . + ", updfla))
}
@@ -29,12 +29,12 @@
bigseed <- get(".Random.seed", envir = .GlobalEnv,
inherits = FALSE)
}
- if (i == 1) {
+ if (.ITRM == 1) {
seed <- attr(tmp, "Random.seed")
sol <- tmp
}
else {
- sol <- rbind(sol[1:(i-1),], as.matrix(tmp[1,]), sol[i,])
+ sol <- rbind(sol[1:(.ITRM-1),], as.matrix(tmp[1,]), sol[.ITRM,])
}
assign(".Random.seed", seed, envir = .GlobalEnv)
}
Modified: pkg/vegan/R/anova.ccabyterm.R
===================================================================
--- pkg/vegan/R/anova.ccabyterm.R 2009-04-27 07:19:23 UTC (rev 814)
+++ pkg/vegan/R/anova.ccabyterm.R 2009-04-27 07:46:39 UTC (rev 815)
@@ -21,21 +21,21 @@
pchi[ntrm, ] <- sim$num
df[ntrm:(ntrm + 1)] <- sim$df
chi[ntrm:(ntrm + 1)] <- sim$chi
- for (i in ntrm:2) {
+ for (.ITRM in ntrm:2) {
if (ntrm < 2)
break
assign(".Random.seed", sim$Random.seed, envir = .GlobalEnv)
- fla <- as.formula(paste(" . ~ . -", trmlab[i]))
+ fla <- as.formula(paste(" . ~ . -", trmlab[.ITRM]))
object <- update(object, fla)
if (is.null(object$CCA))
break
sim <- permutest.cca(object, permutations = step, ...)
- pchi[i, ] <- pchi[i, ] - sim$num
- chi[i] <- chi[i] - sim$chi[1]
- df[i] <- df[i] - sim$df[1]
- pchi[i - 1, ] <- sim$num
- chi[i - 1] <- sim$chi[1]
- df[i - 1] <- sim$df[1]
+ pchi[.ITRM, ] <- pchi[.ITRM, ] - sim$num
+ chi[.ITRM] <- chi[.ITRM] - sim$chi[1]
+ df[.ITRM] <- df[.ITRM] - sim$df[1]
+ pchi[.ITRM - 1, ] <- sim$num
+ chi[.ITRM - 1] <- sim$chi[1]
+ df[.ITRM - 1] <- sim$df[1]
}
Fval <- chi/df/(chi[ntrm + 1]/df[ntrm + 1])
Fval[ntrm + 1] <- NA
Modified: pkg/vegan/inst/ChangeLog
===================================================================
--- pkg/vegan/inst/ChangeLog 2009-04-27 07:19:23 UTC (rev 814)
+++ pkg/vegan/inst/ChangeLog 2009-04-27 07:46:39 UTC (rev 815)
@@ -4,6 +4,11 @@
Version 1.16-18 (opened April 21, 2009)
+ * anova.cca: there was a name clash and failure in
+ anova.ccabymargin, anova.ccabyaxis and anova.ccabyterm if data
+ were indexed with 'i' in the fitted model. Now the internal
+ indexing uses less likely name (.ITRM) to avoid name clashes.
+
* orditkplot: copes with missing or NaN scores (omits them).
* ordixyplot: failed in constrained ordination (cca, rda,
More information about the Vegan-commits
mailing list