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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Mon May 13 07:06:45 CEST 2013


Author: gsimpson
Date: 2013-05-13 07:06:44 +0200 (Mon, 13 May 2013)
New Revision: 326

Added:
   pkg/R/sppResponse.R
   pkg/R/sppResponse.prcurve.R
Modified:
   pkg/inst/ChangeLog
Log:
add sppResponse

Added: pkg/R/sppResponse.R
===================================================================
--- pkg/R/sppResponse.R	                        (rev 0)
+++ pkg/R/sppResponse.R	2013-05-13 05:06:44 UTC (rev 326)
@@ -0,0 +1,3 @@
+`sppResponse` <- function(x, ...) {
+  UseMethod("sppResponse")
+}

Added: pkg/R/sppResponse.prcurve.R
===================================================================
--- pkg/R/sppResponse.prcurve.R	                        (rev 0)
+++ pkg/R/sppResponse.prcurve.R	2013-05-13 05:06:44 UTC (rev 326)
@@ -0,0 +1,13 @@
+`sppResponse.prcurve` <- function(x, n = 100, ...) {
+  Pred <- function(x, n) {
+    rn <- range(x$lambda)
+    newx <- seq(from = rn[1], to = rn[2], length = n)
+    fitted.values <- predict(x$model, x = newx)
+    observed <- x[c("lambda","x")]
+    names(fitted.values) <- names(observed) <- c("gradient","response")
+    list(observed = observed, fitted.values = fitted.values)
+  }
+  out <- lapply(x$smooths, Pred, n = n)
+  class(out) <- "sppResponse"
+  out
+}

Modified: pkg/inst/ChangeLog
===================================================================
--- pkg/inst/ChangeLog	2013-05-13 05:02:27 UTC (rev 325)
+++ pkg/inst/ChangeLog	2013-05-13 05:06:44 UTC (rev 326)
@@ -9,6 +9,10 @@
 	* scores.prcurve: now preserves the rownames on the `lambda`
 	component.
 
+	* sppResponse: new generic function for species responses along
+	gradients. A method is provided for objects of class "prcurve"
+	is the only available method currently.
+
 Version 0.11-2
 
 	* timetrack: plot method now allows plotting of "lc" or "wa"



More information about the Analogue-commits mailing list