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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Thu May 27 14:51:24 CEST 2010


Author: jarioksa
Date: 2010-05-27 14:51:24 +0200 (Thu, 27 May 2010)
New Revision: 1198

Added:
   pkg/vegan/R/scores.ordihull.R
Modified:
   pkg/vegan/R/ordispider.R
   pkg/vegan/inst/ChangeLog
   pkg/vegan/man/ordihull.Rd
Log:
ordispider can now plot (and label) spiders for ordihulls

Modified: pkg/vegan/R/ordispider.R
===================================================================
--- pkg/vegan/R/ordispider.R	2010-05-27 12:12:43 UTC (rev 1197)
+++ pkg/vegan/R/ordispider.R	2010-05-27 12:51:24 UTC (rev 1198)
@@ -11,6 +11,9 @@
         return(invisible())
     }
     pts <- scores(ord, display = display, ...)
+    ## ordihull: draw lines from centre to the points in the hull
+    if (inherits(ord, "ordihull"))
+        groups <- attr(pts, "hulls")
     w <- eval(w)
     if (length(w) == 1)
         w <- rep(1, nrow(pts))

Added: pkg/vegan/R/scores.ordihull.R
===================================================================
--- pkg/vegan/R/scores.ordihull.R	                        (rev 0)
+++ pkg/vegan/R/scores.ordihull.R	2010-05-27 12:51:24 UTC (rev 1198)
@@ -0,0 +1,11 @@
+## Extract the points in the hull as a one matrix
+`scores.ordihull` <-
+    function(x, ...)
+{
+    out <- NULL
+    for(i in 1:length(x))
+        out <- rbind(out, x[[i]])
+    hulls <- rep(names(x), sapply(x, function(z) NROW(z)))
+    attr(out, "hulls") <- hulls
+    out
+}

Modified: pkg/vegan/inst/ChangeLog
===================================================================
--- pkg/vegan/inst/ChangeLog	2010-05-27 12:12:43 UTC (rev 1197)
+++ pkg/vegan/inst/ChangeLog	2010-05-27 12:51:24 UTC (rev 1198)
@@ -4,7 +4,9 @@
 
 Version 1.18-5 (opened May 21, 2010) 
 
-	* ordispider: gained 'label' argument (uses ordilabel()).
+	* ordispider: gained 'label' argument (uses ordilabel()). Can now
+	handle ordihull() result objects: connects points in the line to
+	the hull centroid. Extended examples.
 	
 	* ordiR2step: new function to perform forward model selection
 	following Blanchet, Legendre & Borcard (Ecology 89, 2623-2632;

Modified: pkg/vegan/man/ordihull.Rd
===================================================================
--- pkg/vegan/man/ordihull.Rd	2010-05-27 12:12:43 UTC (rev 1197)
+++ pkg/vegan/man/ordihull.Rd	2010-05-27 12:51:24 UTC (rev 1198)
@@ -10,6 +10,7 @@
 \alias{weights.rda}
 \alias{weights.decorana}
 \alias{summary.ordihull}
+\alias{scores.ordihull}
 \alias{summary.ordiellipse}
 
 \title{Add Graphical Items to Ordination Diagrams}
@@ -102,15 +103,16 @@
   \code{\link[cluster]{ellipsoidhull}} of package \pkg{cluster}.
 
   Functions \code{ordihull} and \code{ordiellipse} return the
-  \code{\link{invisible}} plotting structure. In \code{ordihull} this
-  is a list of coordinates of the hull and in \code{ordiellipse} a
-  list of covariance matrices and scales used in drawing the
-  ellipses. These result objects have a summary method that returns
-  the coordinates of the centres of the ellipses or hulls and their
-  surface areas in user units. The centres of the hulls may differ
-  from the location of the \code{label} which is the centre of the
-  points instead of the centre of the polygon. With \code{draw = "none"}
-  only the result object is returned and nothing is drawn.
+  \code{\link{invisible}} plotting structure. In \code{ordihull} this is
+  a list of coordinates of the hulls (which can be extracted with
+  \code{scores}), and in \code{ordiellipse} a list of covariance
+  matrices and scales used in drawing the ellipses.  These result
+  objects have a \code{summary} method that returns the coordinates of
+  the centres of the ellipses or hulls and their surface areas in user
+  units. The centres of the hulls may differ from the location of the
+  \code{label} which is the centre of the points instead of the centre
+  of the polygon. With \code{draw = "none"} only the result object is
+  returned and nothing is drawn.
 
   Function \code{ordiarrows} draws
   \code{\link{arrows}} and \code{ordisegments} draws line
@@ -120,13 +122,16 @@
   corresponding items among the groups.
 
   Function \code{ordispider} draws a `spider' diagram where each point
-  is connected to the group centroid with
-  \code{\link{segments}}. Weighted centroids are used in the
-  correspondence analysis  methods \code{\link{cca}} and
+  is connected to the group centroid with \code{\link{segments}}. If
+  \code{label = TRUE}, the centroids are labelled using
+  \code{\link{ordilabel}}. Weighted centroids are used in the
+  correspondence analysis methods \code{\link{cca}} and
   \code{\link{decorana}} or if the user gives the weights in the
   call. If \code{ordispider} is called with \code{\link{cca}} or
   \code{\link{rda}} result without \code{groups} argument, the function
-  connects each `WA' scores to the corresponding `LC' score.
+  connects each `WA' scores to the corresponding `LC' score. If the
+  argument is a (\code{invisible}) \code{ordihull} object, the functin
+  will connect the points of the hull to their centroid.
 
   Function \code{ordicluster} overlays a cluster dendrogram onto
   ordination. It needs the result from a hierarchic clustering such as
@@ -162,7 +167,14 @@
 pl <- ordihull(mod, Management, scaling = 3, label = TRUE)
 ## ... and find centres and areas of the hulls
 summary(pl)
-ordispider(mod, col="red", scaling = 3)
+## use ordispider to label and mark the hull
+plot(mod, type = "n")
+pl <- ordihull(mod, Management, scaling = 3)
+ordispider(pl, col="red", lty=3, label = TRUE )
+## ordispider to connect WA and LC scores
+plot(mod, dis=c("wa","lc"), type="p")
+ordispider(mod)
+## Other types of plots
 plot(mod, type = "p", display="sites")
 ordicluster(mod, hclust(vegdist(dune)), prune=3, col = "blue")
 plot(mod, type="n", display = "sites")



More information about the Vegan-commits mailing list