How do I partially bind/apply arguments to a function in R?
This is how far I got, then I realized that this approach doesn’t work…
bind <- function(fun,...)
{
argNames <- names(formals(fun))
bindedArgs <- list(...)
bindedNames <- names(bindedArgs)
function(argNames[!argNames %in% bindedArgs])
{
#TODO
}
}
Thanks!
Have you tried looking at roxygen’s Curry function?
Example usage:
Edit:
Curry is concisely defined to accept named or unnamed arguments, but partial application of
funto arguments by way offormal()assignment requires more sophisticated matching to emulate the same functionality. For instance:Because the first argument in this function is still
a, you need to specify which argument2is intended for (b=), or pass it as the second argument.