Reputation: 1781
I've been recently trying to use rpy2 and import zoo library into python. however, when I run the following sets of code, I receive the following error
from rpy2.robjects.packages import importr
r_zoo = importr("zoo")
r_zoo.rollapply(ddf,FUN = r_func.fun1, width = 10, align = "left",by_column = True)
res = super(Function, self).call(*new_args, **new_kwargs) rpy2.rinterface.RRuntimeError: Error in FUN(data[posns], ...) : unused argument (by_column = TRUE)
The equivalent r code is
rollapply(ddf,FUN = r_func.fun1, width = 10, align = "left",by.column = True)
I understand that when we use the importr from rpy2.robjects.packages it automatically converts the '.'
in Rlang to '_'
in python.
Upvotes: 1
Views: 361
Reputation: 2698
Two ways to get around that problem:
Use a kwargs
dict
r_zoo.rollapply(ddf,FUN = r_func.fun1, width = 10, align = "left",**{"by.column":True})
Explicitly specify that by_column
is to be translated to by.column
from rpy2.robjects.functions import SignatureTranslatedFunction`
r_zoo.rollapply = SignatureTranslatedFunction(r_zoo.rollapply, init_prm_translate = {'by_column': 'by.column'})
Upvotes: 0