Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to pass a function and its arguments through a wrapper function in R? Similar to *args and *kwargs in python

I want to write a wrapper function in R. I should take a function and its arguments. Do something, and then call the function with the supplied arguments.

I know how to do it in python, but I search for an implementation in R. In python I would write:

def wrapper(func, *args, **kwargs):
    #do something here
    return func(*args, **kwargs)
like image 955
Nico Avatar asked Nov 17 '11 10:11

Nico


1 Answers

wrapper <- function(func, ...) {
    func(...)
}
like image 116
Michael Hoffman Avatar answered Oct 25 '22 12:10

Michael Hoffman