[Vegan-commits] r1685 - in pkg/vegan: R inst
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Wed Jul 20 15:38:02 CEST 2011
Author: jarioksa
Date: 2011-07-20 15:38:02 +0200 (Wed, 20 Jul 2011)
New Revision: 1685
Modified:
pkg/vegan/R/anova.ccanull.R
pkg/vegan/R/calibrate.cca.R
pkg/vegan/R/deviance.cca.R
pkg/vegan/R/deviance.rda.R
pkg/vegan/R/ordiplot3d.R
pkg/vegan/R/ordiresids.R
pkg/vegan/R/ordirgl.R
pkg/vegan/R/ordixyplot.R
pkg/vegan/inst/ChangeLog
Log:
fix checking object > 0 in cca/rda/capscale support functions
Modified: pkg/vegan/R/anova.ccanull.R
===================================================================
--- pkg/vegan/R/anova.ccanull.R 2011-07-19 16:29:45 UTC (rev 1684)
+++ pkg/vegan/R/anova.ccanull.R 2011-07-20 13:38:02 UTC (rev 1685)
@@ -5,7 +5,7 @@
function(object, ...)
{
table <- matrix(0, nrow = 2, ncol = 5)
- if (is.null(object$CA)) {
+ if (object$CA$rank == 0) {
table[1,] <- c(object$CCA$qrank, object$CCA$tot.chi, NA, 0, NA)
table[2,] <- c(0,0,NA,NA,NA)
}
@@ -18,9 +18,9 @@
if (inherits(object, "rda")) "Var" else "Chisq",
"F", "N.Perm", "Pr(>F)")
table <- as.data.frame(table)
- if (is.null(object$CA))
+ if (object$CA$rank == 0)
head <- "No residual component\n"
- else if (is.null(object$CCA))
+ else if (is.null(object$CCA) || object$CCA$rank == 0)
head <- "No constrained component\n"
else
head <- c("!!!!! ERROR !!!!!\n")
Modified: pkg/vegan/R/calibrate.cca.R
===================================================================
--- pkg/vegan/R/calibrate.cca.R 2011-07-19 16:29:45 UTC (rev 1684)
+++ pkg/vegan/R/calibrate.cca.R 2011-07-20 13:38:02 UTC (rev 1685)
@@ -3,7 +3,7 @@
{
if (!is.null(object$pCCA))
stop("does not work with conditioned (partial) models")
- if (is.null(object$CCA))
+ if (is.null(object$CCA) || object$CCA$rank == 0)
stop("needs constrained model")
if (object$CCA$rank < object$CCA$qrank)
stop("rank of constraints is higher than rank of dependent data")
Modified: pkg/vegan/R/deviance.cca.R
===================================================================
--- pkg/vegan/R/deviance.cca.R 2011-07-19 16:29:45 UTC (rev 1684)
+++ pkg/vegan/R/deviance.cca.R 2011-07-20 13:38:02 UTC (rev 1685)
@@ -1,8 +1,5 @@
`deviance.cca` <-
function(object, ...)
{
- if (is.null(object$CA))
- 0
- else
- object$CA$tot.chi * object$grand.tot
+ object$CA$tot.chi * object$grand.tot
}
Modified: pkg/vegan/R/deviance.rda.R
===================================================================
--- pkg/vegan/R/deviance.rda.R 2011-07-19 16:29:45 UTC (rev 1684)
+++ pkg/vegan/R/deviance.rda.R 2011-07-20 13:38:02 UTC (rev 1685)
@@ -1,8 +1,5 @@
`deviance.rda` <-
function(object, ...)
{
- if (is.null(object$CA))
- 0
- else
- object$CA$tot.chi * (nrow(object$CA$Xbar) - 1)
+ object$CA$tot.chi * (nrow(object$CA$Xbar) - 1)
}
Modified: pkg/vegan/R/ordiplot3d.R
===================================================================
--- pkg/vegan/R/ordiplot3d.R 2011-07-19 16:29:45 UTC (rev 1684)
+++ pkg/vegan/R/ordiplot3d.R 2011-07-20 13:38:02 UTC (rev 1685)
@@ -16,7 +16,8 @@
col = ax.col)
pl$points3d(c(0, 0), c(0, 0), range(x[, 3]), type = "l",
col = ax.col)
- if (!missing(envfit) || !is.null(object$CCA)) {
+ if (!missing(envfit) ||
+ (!is.null(object$CCA) && object$CCA$rank > 0)) {
if (!missing(envfit))
object <- envfit
bp <- scores(object, dis = "bp", choices = choices, ...)
Modified: pkg/vegan/R/ordiresids.R
===================================================================
--- pkg/vegan/R/ordiresids.R 2011-07-19 16:29:45 UTC (rev 1684)
+++ pkg/vegan/R/ordiresids.R 2011-07-20 13:38:02 UTC (rev 1685)
@@ -4,7 +4,7 @@
{
require(lattice) || stop("requires package lattice")
kind <- match.arg(kind)
- if (!inherits(x, "cca") || is.null(x$CCA))
+ if (!inherits(x, "cca") || is.null(x$CCA) || x$CCA$rank == 0)
stop("function is only available for constrained ordination")
fit <- fitted(x, type = residuals)
res <- residuals(x, type = residuals)
Modified: pkg/vegan/R/ordirgl.R
===================================================================
--- pkg/vegan/R/ordirgl.R 2011-07-19 16:29:45 UTC (rev 1684)
+++ pkg/vegan/R/ordirgl.R 2011-07-20 13:38:02 UTC (rev 1685)
@@ -25,7 +25,8 @@
adj = 0.5)
rgl.texts(0, 0, 1.1 * max(x[, 3]), colnames(x)[3], col = ax.col,
adj = 0.5)
- if (!missing(envfit) || !is.null(object$CCA)) {
+ if (!missing(envfit) ||
+ (!is.null(object$CCA) && object$CCA$rank > 0)) {
if (!missing(envfit))
object <- envfit
bp <- scores(object, dis = "bp", choices = choices)
Modified: pkg/vegan/R/ordixyplot.R
===================================================================
--- pkg/vegan/R/ordixyplot.R 2011-07-19 16:29:45 UTC (rev 1684)
+++ pkg/vegan/R/ordixyplot.R 2011-07-20 13:38:02 UTC (rev 1685)
@@ -12,7 +12,8 @@
v <- colnames(p)
formula <- as.formula(paste(v[2], "~", v[1]))
}
- if ("biplot" %in% type && (!is.null(x$CCA) || !missing(envfit))) {
+ if ("biplot" %in% type && ((!is.null(x$CCA) && x$CCA$rank > 0) ||
+ !missing(envfit))) {
if (missing(envfit))
envfit <- NULL
env <- ordilattice.getEnvfit(formula, x, envfit, choices, ...)
Modified: pkg/vegan/inst/ChangeLog
===================================================================
--- pkg/vegan/inst/ChangeLog 2011-07-19 16:29:45 UTC (rev 1684)
+++ pkg/vegan/inst/ChangeLog 2011-07-20 13:38:02 UTC (rev 1685)
@@ -10,9 +10,10 @@
support functions still checked for is.null() only, although they
also should check if rank == 0. Some functions failed, and these
are fixed here: anova.cca, bstick.cca, goodness.cca/rda,
- predict.cca/rda, screeplot.cca. There are many other functions
- with wrong test, but these didn't fail completely were not fixed
- yet.
+ predict.cca/rda, screeplot.cca. The following functions did not
+ fail, but were fixed: anova.ccanull, calibrate.cca, ordirgl,
+ ordiresids, ordiplot3d, deviance.cca/rda (simplified),
+ ordixyplot.
* swan: gained argument 'maxit' that can be used to restrict the
number of beals() passes on zeros. The default is 'maxit = Inf'
More information about the Vegan-commits
mailing list