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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sat Oct 3 07:29:08 CEST 2009


Author: jarioksa
Date: 2009-10-03 07:29:08 +0200 (Sat, 03 Oct 2009)
New Revision: 1026

Modified:
   pkg/vegan/R/ordiplot.R
   pkg/vegan/R/scores.default.R
   pkg/vegan/inst/ChangeLog
Log:
ordiplot uses linestack with 1-dim scores

Modified: pkg/vegan/R/ordiplot.R
===================================================================
--- pkg/vegan/R/ordiplot.R	2009-10-03 05:07:31 UTC (rev 1025)
+++ pkg/vegan/R/ordiplot.R	2009-10-03 05:29:08 UTC (rev 1026)
@@ -30,12 +30,20 @@
                 warning("Species scores not available")
                 Y <- NULL
             }
-            else if (!is.null(X) && nrow(X) == nrow(Y) &&
-                     identical(all.equal.numeric(X, Y), TRUE)) {
+            else if (!is.null(X) && NROW(X) == NROW(Y) &&
+                     isTRUE(all.equal.numeric(X, Y,
+                                              check.attributes = FALSE))) {
                 Y <- NULL
                 warning("Species scores not available")
             }
         }
+        ## Use linestack and exit if there is only one variable
+        if (NCOL(X) == 1 && NCOL(Y) == 1) {
+            pl <- linestack(X, ylim = range(c(X,Y), na.rm=TRUE), ...)
+            if (!is.null(Y))
+                linestack(Y, side = "left", add = TRUE, ...)
+            return(invisible(pl))
+        }
         tmp <- apply(rbind(X, Y), 2, range, na.rm=TRUE)
         if (missing(xlim)) 
             xlim <- tmp[, 1]

Modified: pkg/vegan/R/scores.default.R
===================================================================
--- pkg/vegan/R/scores.default.R	2009-10-03 05:07:31 UTC (rev 1025)
+++ pkg/vegan/R/scores.default.R	2009-10-03 05:29:08 UTC (rev 1026)
@@ -37,8 +37,7 @@
             X <- x$c1
         else stop("Can't find scores")
     }
-    else if (is.matrix(x)) 
-        X <- x
+    X <- as.matrix(x)
     if (is.null(rownames(X))) {
         root <- substr(display, 1, 4)
         rownames(X) <- paste(root, 1:nrow(X), sep = "")
@@ -46,7 +45,7 @@
     if (is.null(colnames(X))) 
         colnames(X) <- paste("Dim", 1:ncol(X), sep = "")
     if (!missing(choices)) 
-        X <- X[, choices]
+        X <- X[, choices, drop = FALSE]
     X <- as.matrix(X)
     X
 }

Modified: pkg/vegan/inst/ChangeLog
===================================================================
--- pkg/vegan/inst/ChangeLog	2009-10-03 05:07:31 UTC (rev 1025)
+++ pkg/vegan/inst/ChangeLog	2009-10-03 05:29:08 UTC (rev 1026)
@@ -4,6 +4,13 @@
 
 Version 1.16-31 (opened October 3, 2009)
 
+	* ordiplot: uses linestack() to plot 1-col results, and now really
+	is able to identify if there were no species scores (tried
+	earlier, but failed because species had different names than
+	sites). 
+	
+	* scores.default: returns vector scores as 1-col matrix.
+
 	* linestack: passes "..." to plot(), handles missing names.
 	
 Version 1.16-30 (closed October 3, 2009) 



More information about the Vegan-commits mailing list