use_method | R Documentation |
This function calls the specified method, passing along any
arguments that have been specified in args
. It will typically be
used in conjunction with the special object L to dynamically run methods
that have been included as simulation levels. This function is a wrapper
around do.call and is used in a similar manner. See examples.
use_method(method, args = list())
method |
A character string naming a function that has been declared or
loaded via |
args |
A list of arguments to be passed onto |
The result of the call to method
# The following is a toy example of a simulation, illustrating the use of
# the use_method function.
sim <- new_sim()
create_data <- function(n) { rpois(n, lambda=5) }
est_mean_1 <- function(dat) { mean(dat) }
est_mean_2 <- function(dat) { var(dat) }
sim %<>% set_levels(
"n" = c(10, 100, 1000),
"estimator" = c("est_mean_1", "est_mean_2")
)
sim %<>% set_config(num_sim=1)
sim %<>% set_script(function() {
dat <- create_data(L$n)
lambda_hat <- use_method(L$estimator, list(dat))
return (list("lambda_hat"=lambda_hat))
})
sim %<>% run()
sim$results
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.