[Analogue-commits] r298 - in pkg: . R inst man tests/Examples

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Wed Jan 16 13:15:37 CET 2013


Author: gsimpson
Date: 2013-01-16 13:15:36 +0100 (Wed, 16 Jan 2013)
New Revision: 298

Modified:
   pkg/DESCRIPTION
   pkg/R/fitted.timetrack.R
   pkg/R/plot.timetrack.R
   pkg/inst/ChangeLog
   pkg/man/timetrack.Rd
   pkg/tests/Examples/analogue-Ex.Rout.save
Log:
user-friendly improvements to timetrack; move to 0.11-0 for development

Modified: pkg/DESCRIPTION
===================================================================
--- pkg/DESCRIPTION	2013-01-03 12:29:41 UTC (rev 297)
+++ pkg/DESCRIPTION	2013-01-16 12:15:36 UTC (rev 298)
@@ -1,7 +1,7 @@
 Package: analogue
 Type: Package
 Title: Analogue and weighted averaging methods for palaeoecology
-Version: 0.10-0
+Version: 0.11-0
 Date: $Date$
 Depends: R (>= 2.15.0), stats, graphics, vegan (>= 1.17-12), lattice, grid, 
          MASS, princurve, mgcv

Modified: pkg/R/fitted.timetrack.R
===================================================================
--- pkg/R/fitted.timetrack.R	2013-01-03 12:29:41 UTC (rev 297)
+++ pkg/R/fitted.timetrack.R	2013-01-16 12:15:36 UTC (rev 298)
@@ -1,6 +1,6 @@
 `fitted.timetrack` <-
     function(object, type = c("passive", "ordination"),
-             model = NULL, ...)
+             model = NULL, choices = 1:2, ...)
 {
     if(missing(type))
         type <- "passive"
@@ -9,9 +9,10 @@
         if(is.null(object$ordination$CCA)) "CA" else "CCA"
     }
     if(isTRUE(all.equal(type, "passive"))) {
-        fit <- fitted(unclass(object), ...)
+        fit <- fitted(unclass(object), ...)[, choices, drop = FALSE]
     } else {
-        fit <- fitted(object$ordination, model = model, ...)
+        fit <- fitted(object$ordination, model = model,
+                      ...)[, choices, drop = FALSE]
     }
-    return(fit)
+    fit
 }

Modified: pkg/R/plot.timetrack.R
===================================================================
--- pkg/R/plot.timetrack.R	2013-01-03 12:29:41 UTC (rev 297)
+++ pkg/R/plot.timetrack.R	2013-01-16 12:15:36 UTC (rev 298)
@@ -1,10 +1,24 @@
-`plot.timetrack` <- function(x, choices = 1:2,
+`plot.timetrack` <- function(x, choices = 1:2, order,
+                             ptype = c("l", "p", "o", "b"),
                              pch = c(1,2),
                              col = c("black","red"),
+                             lty = "solid", lwd = 1,
                              ...) {
+    ptype <- match.arg(ptype)
     plt <- plot(x$ord, choices = choices, scaling = x$scaling,
                 type = "p", display = "sites", ...,
                 pch = pch[1], col = col[1])
-    ##points(fitted(x)[, choices])
-    lines(fitted(x)[, choices], pch = pch[2], col = col[2])
+    pass <- fitted(x, type = "passive", choices = choices)
+    if(!missing(order)) {
+        if(length(order) != NROW(pass))
+            stop("'length(order)' not equal to number of passive samples.")
+        pass[order, ]
+    }
+    if(ptype %in% c("l", "o", "b")) {
+        lines(pass, pch = pch[2], col = col[2],
+              lty = lty, lwd = lwd, type = ptype, ...)
+    } else {
+        points(pass, pch = pch[2], col = col[2], ...)
+    }
+    invisible()
 }

Modified: pkg/inst/ChangeLog
===================================================================
--- pkg/inst/ChangeLog	2013-01-03 12:29:41 UTC (rev 297)
+++ pkg/inst/ChangeLog	2013-01-16 12:15:36 UTC (rev 298)
@@ -1,5 +1,14 @@
 analogue Change Log
 
+Version 0.11-0
+
+	* timetrack: fitted method gains argument `choices` with
+	default `1:2` for extracting the ordinary or passive
+	samples scores on `choices` axes. `plot` method can now draw
+	the passive samples as a line, points or both. The `plot`
+	method also gains an argument `order` that can be used to
+	reorder the passive samples into correct temporal ordering.
+
 Version 0.10-0
 
 	* Release: Version 0.9-11 plus a minor documentation fix

Modified: pkg/man/timetrack.Rd
===================================================================
--- pkg/man/timetrack.Rd	2013-01-03 12:29:41 UTC (rev 297)
+++ pkg/man/timetrack.Rd	2013-01-16 12:15:36 UTC (rev 298)
@@ -17,10 +17,12 @@
           rank = "full", model = c("CCA", "CA"), \dots)
 
 \method{fitted}{timetrack}(object, type = c("passive", "ordination"),
-       model = NULL, \dots)
+       model = NULL, choices = 1:2, \dots)
 
-\method{plot}{timetrack}(x, choices = 1:2, pch = c(1,2),
-     col = c("black","red"), \dots)
+\method{plot}{timetrack}(x, choices = 1:2, order,
+     ptype = c("l", "p", "o", "b"), pch = c(1,2),
+     col = c("black","red"), lty = "solid", lwd = 1,
+     \dots)
 }
 
 \arguments{
@@ -53,12 +55,22 @@
   \item{type}{character; which fitted values should be returned?}
   \item{choices}{numeric; the length-2 vector of ordination axes to
     plot.}
+  \item{order}{numeric; vector of indices to use to reorder the passive
+    samples. Useful to get passive samples into temporal order for
+    plotting with a line.}
+  \item{ptype}{character; controls how the time track should be
+    drawn. Default is draw the passive samples connected by a line in
+    the order in which they appear in the data. With \code{ptype = "p"}
+    no line is drawn. The other two types have their usual meaning from
+    \code{\link{plot.default}}.}
   \item{pch}{The length-2 vector of plotting characters. The first
     element is used for the ordination samples, the second for the
     passive samples.}
   \item{col}{The length-2 vector of plotting colours. The first
     element is used for the ordination samples, the second for the
     passive samples.}
+  \item{lty, lwd}{graphical parameters for the plotted time track for
+    \code{ptype != "p"}.}
   \item{\dots}{arguments passed to other methods.
     \code{timetrack} passes arguments on to \code{tran} and the
     ordination function given in \code{method}. \code{fitted} passes
@@ -143,7 +155,12 @@
 mod
 
 ## Plot the timetrack
-plot(mod)
+plot(mod, ptype = "b", col = c("forestgreen", "orange"), lwd = 2)
+
+## Other options (reorder the time track)
+ord <- rev(seq_len(nrow(rlgh)))
+plot(mod, choices = 2:3, order = ord, ptype = "b",
+     col = c("forestgreen", "orange"), lwd = 2)
 }
 
 % Add one or more standard keywords, see file 'KEYWORDS' in the

Modified: pkg/tests/Examples/analogue-Ex.Rout.save
===================================================================
--- pkg/tests/Examples/analogue-Ex.Rout.save	2013-01-03 12:29:41 UTC (rev 297)
+++ pkg/tests/Examples/analogue-Ex.Rout.save	2013-01-16 12:15:36 UTC (rev 298)
@@ -31,7 +31,7 @@
 Loading required package: princurve
 Loading required package: mgcv
 This is mgcv 1.7-22. For overview type 'help("mgcv-package")'.
-This is analogue 0.10-0
+This is analogue 0.11-0
 > 
 > assign(".oldSearch", search(), pos = 'CheckExEnv')
 > cleanEx()
@@ -6925,10 +6925,15 @@
 
 > 
 > ## Plot the timetrack
-> plot(mod)
+> plot(mod, ptype = "b", col = c("forestgreen", "orange"), lwd = 2)
 > 
+> ## Other options (reorder the time track)
+> ord <- rev(seq_len(nrow(rlgh)))
+> plot(mod, choices = 2:3, order = ord, ptype = "b",
++      col = c("forestgreen", "orange"), lwd = 2)
 > 
 > 
+> 
 > cleanEx()
 > nameEx("tran")
 > ### * tran
@@ -7365,7 +7370,7 @@
 > ### * <FOOTER>
 > ###
 > cat("Time elapsed: ", proc.time() - get("ptime", pos = 'CheckExEnv'),"\n")
-Time elapsed:  22.741 0.267 23.803 0 0 
+Time elapsed:  21.537 0.227 22.33 0 0 
 > grDevices::dev.off()
 null device 
           1 



More information about the Analogue-commits mailing list