rbartpackages.base.rfunction¶
- rbartpackages.base.rfunction(func, *, library, rname=None)[source]¶
Automatically implement a function using the corresponding R function.
- Parameters:
func (
FunctionType) – A function. Its original implementation is completely discarded.library (
str) – The R package the function is fetched from. The fetch is eager: it happens at decoration time and loads the package namespace.rname (
str|None, default:None) – The name of the function in R. If not specified, use the name offunc.
- Returns:
Callable– An implementation that calls the R function on the converted arguments;RObjectBaseinstances are passed as their wrapped R objects.- Raises:
ValueError – If
libraryorrnameis not a valid R identifier.
Examples
>>> @partial(rfunction, library='mypackage', rname='my.function') ... def my_function(obj: MyRObject, arg1: int, arg2: str): ... ...