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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Mon Oct 31 17:20:20 CET 2011


Author: jarioksa
Date: 2011-10-31 17:20:20 +0100 (Mon, 31 Oct 2011)
New Revision: 1970

Modified:
   pkg/vegan/R/ordispider.R
   pkg/vegan/inst/ChangeLog
   pkg/vegan/man/ordihull.Rd
Log:
ordispider returns the (invisible) plotting structure + update of Rd file

Modified: pkg/vegan/R/ordispider.R
===================================================================
--- pkg/vegan/R/ordispider.R	2011-10-30 18:42:19 UTC (rev 1969)
+++ pkg/vegan/R/ordispider.R	2011-10-31 16:20:20 UTC (rev 1970)
@@ -1,4 +1,4 @@
-"ordispider" <-
+`ordispider` <-
     function (ord, groups, display = "sites", w = weights(ord, display),
               show.groups, label = FALSE, ...)
 {
@@ -8,9 +8,14 @@
         wa <- scores(ord, display = "wa", ...)
         ordiArgAbsorber(lc[, 1], lc[, 2], wa[, 1], wa[, 2],
                         FUN = segments, ...)
-        return(invisible())
+        class(lc) <- "ordispider"
+        return(invisible(lc))
     }
     pts <- scores(ord, display = display, ...)
+    ## spids stores pointwise centroids to be returned invisibly
+    ## (transposed here so that filling is easier, but back-transposed
+    ## when returned).
+    spids <- t(array(NA, dim=dim(pts), dimnames = dimnames(pts)))
     ## ordihull: draw lines from centre to the points in the hull
     if (inherits(ord, "ordihull"))
         groups <- attr(pts, "hulls")
@@ -37,6 +42,7 @@
             X <- pts[gr, ]
             W <- w[gr]
             ave <- apply(X, 2, weighted.mean, w = W)
+            spids[,gr] <- ave
             ordiArgAbsorber(ave[1], ave[2], X[, 1], X[, 2],
                             FUN = segments, ...)
             if (label) {
@@ -47,5 +53,7 @@
     }
     if (label) 
         ordiArgAbsorber(cntrs, label = names, FUN = ordilabel, ...)
-    invisible()
+    spids <- t(spids)
+    class(spids) <- "ordispider"
+    invisible(spids)
 }

Modified: pkg/vegan/inst/ChangeLog
===================================================================
--- pkg/vegan/inst/ChangeLog	2011-10-30 18:42:19 UTC (rev 1969)
+++ pkg/vegan/inst/ChangeLog	2011-10-31 16:20:20 UTC (rev 1970)
@@ -4,6 +4,10 @@
 
 Version 2.1-6 (opened October 30, 2011)
 
+	* ordispider: returns invisibly the coordinates to which each
+	point is connected. Triggered by an email query of this
+	functionality. 
+
 	* ordiplot3d: expanded example to show how to use xyz.convert() to
 	add points as per
 	https://stat.ethz.ch/pipermail/r-help/2011-October/293955.html

Modified: pkg/vegan/man/ordihull.Rd
===================================================================
--- pkg/vegan/man/ordihull.Rd	2011-10-30 18:42:19 UTC (rev 1969)
+++ pkg/vegan/man/ordihull.Rd	2011-10-31 16:20:20 UTC (rev 1970)
@@ -100,27 +100,16 @@
   An ellipsoid hull can be drawn with function
   \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 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{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 \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. If the argument is a (\code{invisible})
-  \code{ordihull} object, the functin will connect the points of the
+  Function \code{ordispider} draws a \sQuote{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
+  \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 \sQuote{WA} scores to the corresponding
+  \sQuote{LC} score. If the argument is a (\code{invisible})
+  \code{ordihull} object, the function will connect the points of the
   hull to their centroid.
 
   Function \code{ordicluster} overlays a cluster dendrogram onto
@@ -137,6 +126,26 @@
   \code{\link{ordisegments}}, \code{\link{ordigrid}}
   and\code{\link{ordiarrows}}.  }
 
+\value{
+
+  Functions \code{ordihull}, \code{ordiellipse} and \code{ordispider}
+  return the \code{\link{invisible}} plotting structure. 
+
+  Function \code{ordispider} return the coordinates to which each
+  point is connected (centroids or \sQuote{LC} scores).
+
+  Function \code{ordihull} returns a list of coordinates of the hulls
+  (which can be extracted with \code{scores}), and \code{ordiellipse}
+  returns 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.
+
+}
+
 \author{ Jari Oksanen }
 
 \seealso{The functions pass parameters to basic graphical functions,



More information about the Vegan-commits mailing list