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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Wed Oct 28 14:39:56 CET 2009


Author: jarioksa
Date: 2009-10-28 14:39:56 +0100 (Wed, 28 Oct 2009)
New Revision: 1061

Modified:
   pkg/vegan/R/ordisurf.R
   pkg/vegan/inst/ChangeLog
Log:
ordisurf: NA handling in r1049 broke plot main title + tinkering

Modified: pkg/vegan/R/ordisurf.R
===================================================================
--- pkg/vegan/R/ordisurf.R	2009-10-28 13:12:46 UTC (rev 1060)
+++ pkg/vegan/R/ordisurf.R	2009-10-28 13:39:56 UTC (rev 1061)
@@ -5,16 +5,21 @@
               bubble = FALSE, cex = 1, ...) 
 {
     weights.default <- function(object, ...) NULL
-    GRID = 25
+    GRID = 31
     w <- eval(w)
     if (!is.null(w) && length(w) == 1) 
         w <- NULL
     require(mgcv)  || stop("Requires package 'mgcv'")
     X <- scores(x, choices = choices, display = display, ...)
+    ## The original name of 'y' may be lost in handling NA: save for
+    ## plots
+    yname <- deparse(substitute(y))
     kk <- complete.cases(X) & !is.na(y)
-    X <- X[kk, , drop = FALSE]
-    y <- y[kk]
-    w <- w[kk]
+    if (!all(kk)) {
+        X <- X[kk, , drop = FALSE]
+        y <- y[kk]
+        w <- w[kk]
+    }
     x1 <- X[, 1]
     x2 <- X[, 2]
     if (knots <= 0)
@@ -37,8 +42,8 @@
     poly <- chull(cbind(x1,x2))
     ## Move out points of the convex hull to have contour for all data
     ## points
-    xhull1 <- x1[poly] + sign(x1[poly] - mean(x1[poly])) * diff(range(x1))/GRID
-    xhull2 <- x2[poly] + sign(x2[poly] - mean(x2[poly])) * diff(range(x2))/GRID
+    xhull1 <- x1[poly] + sign(x1[poly] - mean(x1[poly])) * diff(range(x1))/(GRID - 1)
+    xhull2 <- x2[poly] + sign(x2[poly] - mean(x2[poly])) * diff(range(x2))/(GRID - 1)
     npol <- length(poly)
     np <- nrow(newd)
     inpoly <- numeric(np)
@@ -56,7 +61,7 @@
     }
     if (!missing(main) || (missing(main) && !add)) {
         if (missing(main)) 
-            main <- deparse(substitute(y))
+            main <- yname
         title(main = main)
     }
     if (missing(levels)) 

Modified: pkg/vegan/inst/ChangeLog
===================================================================
--- pkg/vegan/inst/ChangeLog	2009-10-28 13:12:46 UTC (rev 1060)
+++ pkg/vegan/inst/ChangeLog	2009-10-28 13:39:56 UTC (rev 1061)
@@ -4,6 +4,10 @@
 
 Version 1.16-32 (opened October 24, 2009)
 
+	* ordisurf: plotting main title was broken with NA handling in
+	1.16-31 (r1049). Also increased grid density and adjusted pushing
+	out limits of convex hull.
+
 	* pcnm: new function for PCNM (Principal Coordinates of
 	Neighbourhood Matrix) with option for row weighs allowing PCNM for
 	cca. Based on Stéphane Dray's PCNM function in his (unreleased)



More information about the Vegan-commits mailing list