wrapper | R Documentation |
Create a call that can be substituted into a wrapper function.
wrapper(fun, defaults = NULL, with.pkg = TRUE)
fun |
a character string, symbol or call. |
defaults |
a list of default arguments for the call, or |
with.pkg |
logical; if the function is from a namespace, should the namespace name be used in the call? |
A wrapper function is a function whose purpose is to call another function. Wrapper functions are useful for hiding details of a function's implementation.
A call.
# I don't particularly like that the function data.frame has
# the formal argument "check.names" default to TRUE. Here, we
# will use 'wrapper' to make a wrapper for data.frame that has
# "check.names" set to FALSE
# we want the function body to look like this
wrapper(data.frame)
## make the function with the appropriate function body
data.frame2 <- function() NULL
body(data.frame2) <- wrapper(data.frame)
## add the function formals, changing "check.names" from TRUE to FALSE
formals(data.frame2) <- formals(data.frame)
formals(data.frame2)$check.names <- FALSE
print(data.frame2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.