[Vegan-commits] r2723 - pkg/permute/R
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Thu Nov 21 17:30:03 CET 2013
Author: gsimpson
Date: 2013-11-21 17:30:03 +0100 (Thu, 21 Nov 2013)
New Revision: 2723
Added:
pkg/permute/R/fixupCall.R
Log:
add fixupCall(), a new function to programmatically update the call stored in the how object.
Added: pkg/permute/R/fixupCall.R
===================================================================
--- pkg/permute/R/fixupCall.R (rev 0)
+++ pkg/permute/R/fixupCall.R 2013-11-21 16:30:03 UTC (rev 2723)
@@ -0,0 +1,12 @@
+## Non-exported function that can be used to fix up elements of a call
+`fixupCall` <- function(object, element, value) {
+ ## element must be character! Try to coerce
+ element <- as.character(element) ## Fails if not coercible
+ .call <- getElement(object, "call") ## get call from object
+ .ll <- as.list(.call) ## convert to a list to manipulate
+ names(.ll) <- names(.call) ## set names on the list
+ .ll[[element]] <- value ## set element to value
+ .call <- as.call(.ll) ## convert back to a call
+ object$call <- .call ## push back into object
+ object
+}
More information about the Vegan-commits
mailing list