Description Usage Arguments Value See Also Examples
Read the function arguments and function results that were stored in RData
files (in objects args
and result
, respectively) by a previous
call of saveArgs
.
1 |
functionName |
Name of the function to load arguments and results for.
The name is used to create a search pattern for RData files in
|
data.dir |
Directory in which to look for RData files matching
|
list with as many items as there were files args_<functionName>_*
in the directory given in data.dir
. Each list element has two
components: args
containing the arguments that were given to
the function and result
containing what the function returned.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | # Define a function that stores its arguments and result with saveArgs
double <- function(x) {
result <- 2 * x
saveArgs("double", args = list(x = x), result = result)
result
}
# Set global variable TESTMODE to "activate" saveArgs() in double()
TESTMODE <- TRUE
# Call the function a couple of times
double(4)
double(-99)
double(1:10)
# Load what was stored behind the scenes
testdata <- loadArgs("double")
# "Deactivate" saveArgs() in double()
TESTMODE <- FALSE
# Rerun the function with the stored arguments
results <- lapply(testdata, function(x) do.call("double", x$args))
# Compare the new with the old results
identical(results, lapply(testdata, "[[", "result"))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.