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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Thu Jan 5 09:58:13 CET 2012


Author: jarioksa
Date: 2012-01-05 09:58:12 +0100 (Thu, 05 Jan 2012)
New Revision: 2036

Modified:
   pkg/vegan/R/plot.cca.R
   pkg/vegan/inst/ChangeLog
Log:
plot.cca stops with comprehensible error when user asks for non-existing scores

Modified: pkg/vegan/R/plot.cca.R
===================================================================
--- pkg/vegan/R/plot.cca.R	2012-01-05 08:31:16 UTC (rev 2035)
+++ pkg/vegan/R/plot.cca.R	2012-01-05 08:58:12 UTC (rev 2036)
@@ -4,10 +4,12 @@
 {
     TYPES <- c("text", "points", "none")
     g <- scores(x, choices, display, scaling, const)
+    if (length(g) == 0)
+      stop("nothing to plot: requested scores do not exist")
     if (!is.list(g)) 
         g <- list(default = g)
     ## Take care that there are names
-    for (i in 1:length(g)) {
+    for (i in seq_len(length(g))) {
         if (length(dim(g[[i]])) > 1)
             rownames(g[[i]]) <- rownames(g[[i]], do.NULL = FALSE,
                                          prefix = substr(names(g)[i], 1, 3))

Modified: pkg/vegan/inst/ChangeLog
===================================================================
--- pkg/vegan/inst/ChangeLog	2012-01-05 08:31:16 UTC (rev 2035)
+++ pkg/vegan/inst/ChangeLog	2012-01-05 08:58:12 UTC (rev 2036)
@@ -22,7 +22,9 @@
 	that in the printed output.
 
 	* plot.cca: works with degenerate solutions where constraints are
-	aliased and 'biplot' scores have zero rows.
+	aliased and 'biplot' scores have zero rows. Stops with a
+	comprehensible error message if a user requests non-existing
+	scores (such as "bp" scores for unconstrained ordination).
 	
 	* rarecurve: new function to draw rarefaction curves for each
 	plot, optionally with sample size vertical and corresponding



More information about the Vegan-commits mailing list