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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sun Oct 4 10:27:08 CEST 2009


Author: jarioksa
Date: 2009-10-04 10:27:06 +0200 (Sun, 04 Oct 2009)
New Revision: 1030

Modified:
   pkg/vegan/R/ordisurf.R
   pkg/vegan/inst/ChangeLog
Log:
ordisurf: contours cover the points better at margins

Modified: pkg/vegan/R/ordisurf.R
===================================================================
--- pkg/vegan/R/ordisurf.R	2009-10-03 09:44:06 UTC (rev 1029)
+++ pkg/vegan/R/ordisurf.R	2009-10-04 08:27:06 UTC (rev 1030)
@@ -31,11 +31,14 @@
     newd <- expand.grid(x1 = xn1, x2 = xn2)
     fit <- predict(mod, type = "response", newdata=as.data.frame(newd))
     poly <- chull(cbind(x1,x2))
-    poly <- c(poly, poly[1])
+    ## 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
     npol <- length(poly)
     np <- nrow(newd)
     inpoly <- numeric(np)
-    inpoly <- .C("pnpoly", as.integer(npol), as.double(x1[poly]), as.double(x2[poly]),
+    inpoly <- .C("pnpoly", as.integer(npol), as.double(xhull1), as.double(xhull2),
                  as.integer(np), as.double(newd[,1]), as.double(newd[,2]),
                  inpoly = as.integer(inpoly), PACKAGE="vegan")$inpoly
     is.na(fit) <- inpoly == 0

Modified: pkg/vegan/inst/ChangeLog
===================================================================
--- pkg/vegan/inst/ChangeLog	2009-10-03 09:44:06 UTC (rev 1029)
+++ pkg/vegan/inst/ChangeLog	2009-10-04 08:27:06 UTC (rev 1030)
@@ -4,6 +4,9 @@
 
 Version 1.16-31 (opened October 3, 2009)
 
+	* ordisurf: pushes out limits of convex hull so that contours
+	better cover corners and margins of points.
+
 	* plot.decorana & plot.cca: use linestack() if only one dimension
 	was chosen.
 



More information about the Vegan-commits mailing list