amodule | R Documentation |
amodule
is a wrapper around module and changes the default
environment to which the module connects. In contrast to module
the top enclosing environment here is always baseenv
. The second
important difference is that the environment in which a module is created has
meaning: all objects are made available to the module scope. This is
what is meant by augmented or parameterized. Best practice for
the use of this behavior is to return these modules from functions.
amodule(expr = {
}, envir = parent.frame(), enclos = baseenv(), class = NULL)
expr |
(expression) a module declaration, same as module |
envir |
(environment) environment used to detect 'parameters' |
enclos |
(environment) the top enclosing environment of the module scope. |
class |
(character) the module can have a class attribute for consistency. If you rely on S3 dispatch, e.g. to override the default print method, you should set this value explicitly. |
Constructor <- function(dependency) {
amodule({
fun <- function(...) dependency(...)
})
}
instance <- Constructor(identity)
instance$fun(1)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.