I\'m new to rpy2 and am having trouble using importr to import the R packages \'xts\' and \'quantmod\'
Code is:
from rpy2.robjects.packages import im
Rpy2's importr()
is trying to convert any "." in R object names to "_" for usage with Python.
However, whenever there are two R object names with either "." or "_" (both characters are valid for names in R) rpy2 is reporting an error. Here the R package "xts" is defining the two objects .subset_xts
and .subset.xts
. The workaround is specify manually how to convert names:
from rpy2.robjects.packages import import
xts = importr("xts", robject_translations = {".subset.xts": "_subset_xts2",
"to.period": "to_period2"})
More is available in the rpy2 documentation about importing R packages.