Description Usage Arguments Details Examples
argumentDeparser
passes arg = .(key1 = value1, key2 = value2)
function arguments to the appropriate function
1 2 3 4 5 6 | argumentDeparser(
arg,
replace_dot,
transform_logical = TRUE,
null_params = NULL
)
|
arg |
an unevaluated call, see Details |
replace_dot |
a character string which defines the function to which
|
transform_logical |
logical; if TRUE (default), a single logical
|
null_params |
a list of parameters which is passed to the parameter
setter function (see 'replace_dot') if |
This function is not intended for direct use. It allows
method = .(key = value)
argument definition in high-level functions
by substituting .
to the appriopriate methodParams
function. If transform_logical
is TRUE, the call
method = TRUE
is transformed to method = methodParams()
,
thereby it returns the default parameter setting. Similarily,
method = FALSE
is treated as method = NULL
.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | mymethodParams <- function(x = 3, y = 4) {
list(x = x, y = y)
}
tempfn <- function(mymethod = NULL, ...) {
argumentDeparser(substitute(mymethod), "mymethodParams", ...)
}
stopifnot(is.null(tempfn()))
stopifnot(identical(tempfn(null_params = list(x = 1)),
list(x = 1, y = 4)))
stopifnot(identical(FALSE,
tempfn(mymethod = FALSE, transform_logical = FALSE)))
stopifnot(identical(tempfn(mymethod = TRUE),
tempfn(mymethod = mymethodParams())))
new_y = 1:5
stopifnot(identical(tempfn(mymethod = .(y = new_y)),
tempfn(mymethod = mymethodParams(y = new_y))))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.