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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Thu Nov 3 08:23:38 CET 2011


Author: jarioksa
Date: 2011-11-03 08:23:37 +0100 (Thu, 03 Nov 2011)
New Revision: 1985

Modified:
   pkg/vegan/R/ordiarrows.R
   pkg/vegan/R/ordisegments.R
   pkg/vegan/inst/ChangeLog
   pkg/vegan/man/ordiarrows.Rd
Log:
ordiarrows & ordisegments gained arg 'order.by' to order points within 'groups'

Modified: pkg/vegan/R/ordiarrows.R
===================================================================
--- pkg/vegan/R/ordiarrows.R	2011-11-02 20:36:35 UTC (rev 1984)
+++ pkg/vegan/R/ordiarrows.R	2011-11-03 07:23:37 UTC (rev 1985)
@@ -1,11 +1,19 @@
-"ordiarrows" <-
-    function (ord, groups, levels, replicates, display = "sites",
-              show.groups, startmark, label = FALSE, ...)
+`ordiarrows` <-
+    function (ord, groups, levels, replicates, order.by, 
+              display = "sites", show.groups, startmark, label = FALSE, ...)
 {
     pts <- scores(ord, display = display, ...)
     npoints <- nrow(pts)
     if (missing(groups))
         groups <- gl(levels, replicates, npoints)
+    if (!missing(order.by)) {
+        if (length(order.by) != nrow(pts))
+            stop(gettextf("the length of order.by (%d) does not match the number of points (%d)",
+                 length(order.by), nrow(pts)))
+        ord <- order(order.by)
+        pts <- pts[ord,]
+        groups <- groups[ord]
+    }
     if (!missing(show.groups)) {
         take <- groups %in% show.groups
         pts <- pts[take, , drop = FALSE]

Modified: pkg/vegan/R/ordisegments.R
===================================================================
--- pkg/vegan/R/ordisegments.R	2011-11-02 20:36:35 UTC (rev 1984)
+++ pkg/vegan/R/ordisegments.R	2011-11-03 07:23:37 UTC (rev 1985)
@@ -1,11 +1,19 @@
-"ordisegments" <-
-    function (ord, groups, levels, replicates, display = "sites",
+`ordisegments` <-
+    function (ord, groups, levels, replicates, order.by, display = "sites",
               show.groups, label = FALSE, ...)
 {
     pts <- scores(ord, display = display, ...)
     npoints <- nrow(pts)
     if (missing(groups))
         groups <- gl(levels, replicates, npoints)
+    if (!missing(order.by)) {
+        if (length(order.by) != nrow(pts))
+            stop(gettextf("the length of order.by (%d) does not match the number of points (%d)",
+                 length(order.by), nrow(pts)))
+        ord <- order(order.by)
+        pts <- pts[ord,]
+        groups <- groups[ord]
+    }
     if (!missing(show.groups)) {
         take <- groups %in% show.groups
         pts <- pts[take, , drop = FALSE]

Modified: pkg/vegan/inst/ChangeLog
===================================================================
--- pkg/vegan/inst/ChangeLog	2011-11-02 20:36:35 UTC (rev 1984)
+++ pkg/vegan/inst/ChangeLog	2011-11-03 07:23:37 UTC (rev 1985)
@@ -9,6 +9,11 @@
 	of environmental arrows in cca/rda/capscale/envfit, plus some
 	minor updates of old entries.
 
+	* ordiarrows, ordisegments: gained argument 'order.by' that can be
+	used to order the points within groups before drawing the arrows
+	or segments. This message in R-sig-ecology seems to need this: 
+	https://stat.ethz.ch/pipermail/r-sig-ecology/2011-November/002464.html
+
 	* ordispider: returns invisibly the coordinates to which each
 	point is connected. Triggered by an email query of this
 	functionality. 

Modified: pkg/vegan/man/ordiarrows.Rd
===================================================================
--- pkg/vegan/man/ordiarrows.Rd	2011-11-02 20:36:35 UTC (rev 1984)
+++ pkg/vegan/man/ordiarrows.Rd	2011-11-03 07:23:37 UTC (rev 1985)
@@ -11,9 +11,9 @@
   \code{\link{ordiplot}}.  }
 
 \usage{
-ordiarrows(ord, groups, levels, replicates, display = "sites",
+ordiarrows(ord, groups, levels, replicates, order.by, display = "sites",
          show.groups, startmark, label = FALSE, ...)
-ordisegments(ord, groups, levels, replicates, display = "sites",
+ordisegments(ord, groups, levels, replicates, order.by, display = "sites",
          show.groups, label = FALSE, ...)
 ordigrid(ord, levels, replicates, display = "sites",  lty = c(1,1), 
          col = c(1,1), lwd = c(1,1), ...)
@@ -28,6 +28,9 @@
     \code{replicates}, where \code{levels} gives the number of groups,
     and \code{replicates} the number of successive items at the same
     group.}
+  \item{order.by}{Order points by increasing order of this variable
+    within \code{groups}. Reverse sign of the variable for decreasing
+    ordering.} 
   \item{display}{Item to displayed. }
   \item{show.groups}{Show only given groups. This can be a vector, or
     \code{TRUE} if you want to show items for which condition is



More information about the Vegan-commits mailing list