[Analogue-commits] r327 - in pkg: R inst

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Mon May 13 07:11:39 CEST 2013


Author: gsimpson
Date: 2013-05-13 07:11:39 +0200 (Mon, 13 May 2013)
New Revision: 327

Added:
   pkg/R/plot.sppResponse.R
Modified:
   pkg/inst/ChangeLog
Log:
add plot method for sppResponse

Added: pkg/R/plot.sppResponse.R
===================================================================
--- pkg/R/plot.sppResponse.R	                        (rev 0)
+++ pkg/R/plot.sppResponse.R	2013-05-13 05:11:39 UTC (rev 327)
@@ -0,0 +1,29 @@
+`plot.sppResponse` <- function(x, which = seq_along(x),
+                               display = c("observed","fitted"),
+                               xlab = "Gradient",
+                               ylab = "Abundance",
+                               main = NULL,
+                               lcol = "red",
+                               lwd = 2,
+                               ...) {
+  display <- match.arg(display)
+
+  noMain <- is.null(main)
+  if (noMain) {
+    nams <- names(x)
+  }
+  
+  for (i in which) {
+    ox <- x[[i]]$observed$gradient
+    oy <- x[[i]]$observed$response
+    fx <- x[[i]]$fitted.values$gradient
+    fy <- x[[i]]$fitted.values$response
+    xlim <- range(ox, fx)
+    ylim <- range(oy, fy)
+    if (noMain)
+      main <- nams[i]
+    plot(ox, oy, xlim = xlim, ylim = ylim, ylab = ylab, xlab = xlab,
+         main = main, ...)
+    lines(fx, fy, col = lcol, lwd = lwd, ...)
+  }
+}

Modified: pkg/inst/ChangeLog
===================================================================
--- pkg/inst/ChangeLog	2013-05-13 05:06:44 UTC (rev 326)
+++ pkg/inst/ChangeLog	2013-05-13 05:11:39 UTC (rev 327)
@@ -11,7 +11,8 @@
 
 	* sppResponse: new generic function for species responses along
 	gradients. A method is provided for objects of class "prcurve"
-	is the only available method currently.
+	is the only available method currently. A `plot()` method for
+	`sppResponse()` objects is also provided.
 
 Version 0.11-2
 



More information about the Analogue-commits mailing list