[Vegan-commits] r1684 - in pkg/vegan: R inst man
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Tue Jul 19 18:29:45 CEST 2011
Author: jarioksa
Date: 2011-07-19 18:29:45 +0200 (Tue, 19 Jul 2011)
New Revision: 1684
Modified:
pkg/vegan/R/bstick.cca.R
pkg/vegan/R/goodness.cca.R
pkg/vegan/R/goodness.rda.R
pkg/vegan/R/predict.cca.R
pkg/vegan/R/predict.rda.R
pkg/vegan/R/screeplot.cca.R
pkg/vegan/inst/ChangeLog
pkg/vegan/man/screeplot.cca.Rd
Log:
cca support functions failed if component was zero instead of NULL
Modified: pkg/vegan/R/bstick.cca.R
===================================================================
--- pkg/vegan/R/bstick.cca.R 2011-07-19 12:19:35 UTC (rev 1683)
+++ pkg/vegan/R/bstick.cca.R 2011-07-19 16:29:45 UTC (rev 1684)
@@ -3,7 +3,7 @@
{
if(!inherits(n, c("rda", "cca")))
stop("'n' not of class \"cca\" or \"rda\"")
- if(!is.null(n$CCA))
+ if(!is.null(n$CCA) && n$CCA$rank > 0)
stop("'bstick' only for unconstrained models.")
## No idea how to define bstick for capscale with negative
## eigenvalues
Modified: pkg/vegan/R/goodness.cca.R
===================================================================
--- pkg/vegan/R/goodness.cca.R 2011-07-19 12:19:35 UTC (rev 1683)
+++ pkg/vegan/R/goodness.cca.R 2011-07-19 16:29:45 UTC (rev 1684)
@@ -6,7 +6,7 @@
model <- match.arg(model)
if (is.null(object$CCA))
model <- "CA"
- if (is.null(object[[model]]))
+ if (is.null(object[[model]]) || object[[model]]$rank == 0)
stop("model ", model, " is not available")
statistic <- match.arg(statistic)
display <- match.arg(display)
Modified: pkg/vegan/R/goodness.rda.R
===================================================================
--- pkg/vegan/R/goodness.rda.R 2011-07-19 12:19:35 UTC (rev 1683)
+++ pkg/vegan/R/goodness.rda.R 2011-07-19 16:29:45 UTC (rev 1684)
@@ -9,7 +9,7 @@
stop("display = \"species\" not available for 'capscale'")
if (is.null(object$CCA))
model <- "CA"
- if (is.null(object[[model]]))
+ if (is.null(object[[model]]) || object[[model]]$rank == 0)
stop("model ", model, " is not available")
statistic <- match.arg(statistic)
cs <- weights(object, display = display)
Modified: pkg/vegan/R/predict.cca.R
===================================================================
--- pkg/vegan/R/predict.cca.R 2011-07-19 12:19:35 UTC (rev 1683)
+++ pkg/vegan/R/predict.cca.R 2011-07-19 16:29:45 UTC (rev 1684)
@@ -7,6 +7,8 @@
if (model == "CCA" && is.null(object$CCA))
model <- "CA"
take <- object[[model]]$rank
+ if (take == 0)
+ stop("model ", dQuote(model), " has rank 0")
if (rank != "full")
take <- min(take, rank)
rs <- object$rowsum
Modified: pkg/vegan/R/predict.rda.R
===================================================================
--- pkg/vegan/R/predict.rda.R 2011-07-19 12:19:35 UTC (rev 1683)
+++ pkg/vegan/R/predict.rda.R 2011-07-19 16:29:45 UTC (rev 1684)
@@ -7,6 +7,8 @@
if (model == "CCA" && is.null(object$CCA))
model <- "CA"
take <- object[[model]]$rank
+ if (take == 0)
+ stop("model ", dQuote(model), " has rank 0")
if (rank != "full")
take <- min(take, rank)
if (is.null(object$CCA))
Modified: pkg/vegan/R/screeplot.cca.R
===================================================================
--- pkg/vegan/R/screeplot.cca.R 2011-07-19 12:19:35 UTC (rev 1683)
+++ pkg/vegan/R/screeplot.cca.R 2011-07-19 16:29:45 UTC (rev 1684)
@@ -1,11 +1,11 @@
`screeplot.cca` <-
function(x, bstick = FALSE, type = c("barplot", "lines"),
- npcs = min(10, if(is.null(x$CCA)) x$CA$rank else x$CCA$rank),
+ npcs = min(10, if(is.null(x$CCA) || x$CCA$rank == 0) x$CA$rank else x$CCA$rank),
ptype = "o", bst.col = "red", bst.lty = "solid",
xlab = "Component", ylab = "Inertia",
main = deparse(substitute(x)), legend = bstick, ...)
{
- if(is.null(x$CCA))
+ if(is.null(x$CCA) || x$CCA$rank == 0)
eig.vals <- x$CA$eig
else
eig.vals <- x$CCA$eig
@@ -14,7 +14,7 @@
npcs <- ncomps
comps <- seq(len=npcs)
type <- match.arg(type)
- if (bstick && !is.null(x$CCA)) {
+ if (bstick && !is.null(x$CCA) && x$CCA$rank > 0) {
warning("'bstick' unavailable for constrained ordination")
bstick <- FALSE
}
Modified: pkg/vegan/inst/ChangeLog
===================================================================
--- pkg/vegan/inst/ChangeLog 2011-07-19 12:19:35 UTC (rev 1683)
+++ pkg/vegan/inst/ChangeLog 2011-07-19 16:29:45 UTC (rev 1684)
@@ -4,9 +4,15 @@
Version 1.90-1 (opened July 3, 2011)
- * anova.cca: failed (bug) if CCA object had rank zero. This was
- broken by the new CCA return object, where completely aliased
- constraints do not give NULL component but a zero rank component.
+ * cca/rda/capscale support functions: cca/rda/capscale were
+ changed to return zero components instead of NULL for completely
+ aliased constraints (CCA) or saturated models (CA), but several
+ 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.
* swan: gained argument 'maxit' that can be used to restrict the
number of beals() passes on zeros. The default is 'maxit = Inf'
Modified: pkg/vegan/man/screeplot.cca.Rd
===================================================================
--- pkg/vegan/man/screeplot.cca.Rd 2011-07-19 12:19:35 UTC (rev 1683)
+++ pkg/vegan/man/screeplot.cca.Rd 2011-07-19 16:29:45 UTC (rev 1684)
@@ -17,7 +17,7 @@
}
\usage{
\method{screeplot}{cca}(x, bstick = FALSE, type = c("barplot", "lines"),
- npcs = min(10, if (is.null(x$CCA)) x$CA$rank else x$CCA$rank),
+ npcs = min(10, if (is.null(x$CCA) || x$CCA$rank == 0) x$CA$rank else x$CCA$rank),
ptype = "o", bst.col = "red", bst.lty = "solid",
xlab = "Component", ylab = "Inertia",
main = deparse(substitute(x)), legend = bstick,
More information about the Vegan-commits
mailing list