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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sat Mar 15 17:27:27 CET 2014


Author: gsimpson
Date: 2014-03-15 17:27:26 +0100 (Sat, 15 Mar 2014)
New Revision: 2862

Modified:
   pkg/vegan/R/plot.envfit.R
   pkg/vegan/inst/ChangeLog
Log:
handle case where there are no useful rownames stored and labels is a vector input

Modified: pkg/vegan/R/plot.envfit.R
===================================================================
--- pkg/vegan/R/plot.envfit.R	2014-02-21 10:41:49 UTC (rev 2861)
+++ pkg/vegan/R/plot.envfit.R	2014-03-15 16:27:26 UTC (rev 2862)
@@ -19,9 +19,12 @@
             ## and the existing set of labels is replaced
             if (!is.null(labs$v) && !is.null(labs$f))
                 stop("needs a list with both 'vectors' and 'factors' labels")
-            if (!is.null(labs$v))
+            ## need to handle the case where both sets of labels are NULL
+            ## such as when used with the default interface and single x
+            ln <- sapply(labs, is.null)
+            if (ln["v"])
                 labs$v <- labels
-            else
+            if (ln["f"])
                 labs$f <- labels
         }
     }
@@ -102,7 +105,7 @@
         xlim <- range(xstack[,1] + sw, xstack[,2] - sw)
         ylim <- range(xstack[,2] + sh, xstack[,2] - sh)
         plot.window(xlim = xlim, ylim = ylim, asp = 1, ...)
-        ## Re-evaluate arrow.mul, set its text and re-evaluate limits again 
+        ## Re-evaluate arrow.mul, set its text and re-evaluate limits again
         if (!is.null(vect)) {
             arrow.mul <- ordiArrowMul(vect, at = at, fill = 1)
             vect <- arrow.mul * vect
@@ -119,7 +122,7 @@
         alabs <- colnames(vect)
         title(..., ylab = alabs[2], xlab = alabs[1])
     }
-    
+
     if (!is.null(vect)) {
         arrows(at[1], at[2], vect[, 1], vect[, 2], len = 0.05,
                col = col)

Modified: pkg/vegan/inst/ChangeLog
===================================================================
--- pkg/vegan/inst/ChangeLog	2014-02-21 10:41:49 UTC (rev 2861)
+++ pkg/vegan/inst/ChangeLog	2014-03-15 16:27:26 UTC (rev 2862)
@@ -105,7 +105,12 @@
 	Flavniva). In addition, Dip.mon was corrected to Diphcomp
 	(Diphasiastrum complanatum, should perhaps be Lycopodium c.), and
 	Barbilophozia lycopodioides to B. hatcheri.
-	
+
+	* plot.envfit: when `envfit()` is called as
+	`envfit(ord, foo[, "bar"])`, there are no useful rownames on the
+	objects returned. Hence the logic in `plot.envfit()` when called
+	with argument `labels` was failing.
+
 Version 2.1-40 (closed December 12, 2013)	
 	
 	* anova.cca: Function is now based on the new code, but the old is



More information about the Vegan-commits mailing list