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

本秂侑毒 提交于 2019-11-28 03:46:31

问题


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)

回答1:


wrapper <- function(func, ...) {
    func(...)
}


来源:https://stackoverflow.com/questions/8165837/how-to-pass-a-function-and-its-arguments-through-a-wrapper-function-in-r-simila

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!