I have been following the instructions on Working with R's OOPS in the rpy2 documentation here: https://rpy2.readthedocs.io/en/version_2.8.x/robjects_oop.html and I am trying to create a Python class to call the function rfsrc in the R package randomForestSRC.
When I run the code below from a Jupyter Notebook (Python 3, R 3.5.1), I get the error:
Error in (function (f, signature = character(), where = topenv(parent.frame()), : no generic function found for 'rfsrc'.
Does this mean that I cannot call rfsrc from Python? Thanks.
`import rpy2.robjects.packages as rpackages
from rpy2.robjects.vectors import StrVector
utils = rpackages.importr('utils')
utils.chooseCRANmirror(ind=1) # select the first mirror in the list
packnames = ('randomForestSRC', 'survival', 'tidyverse', 'magrittr', 'ggRandomForests', 'mlr')
utils.install_packages(StrVector(packnames))
from rpy2.robjects.packages import importr
randomForestSRC = importr('randomForestSRC')
from rpy2.robjects.methods import RS4Auto_Type
import six
class rfsrc(six.with_metaclass(RS4Auto_Type)):
rname = 'rfsrc'
rpackagename = 'randomForestSRC'`
I have been following the instructions on Working with R's OOPS in the rpy2 documentation here: https://rpy2.readthedocs.io/en/version_2.8.x/robjects_oop.html and I am trying to create a Python class to call the function rfsrc in the R package randomForestSRC.
When I run the code below from a Jupyter Notebook (Python 3, R 3.5.1), I get the error: Error in (function (f, signature = character(), where = topenv(parent.frame()), : no generic function found for 'rfsrc'.
Does this mean that I cannot call rfsrc from Python? Thanks.
`import rpy2.robjects.packages as rpackages from rpy2.robjects.vectors import StrVector
utils = rpackages.importr('utils') utils.chooseCRANmirror(ind=1) # select the first mirror in the list packnames = ('randomForestSRC', 'survival', 'tidyverse', 'magrittr', 'ggRandomForests', 'mlr') utils.install_packages(StrVector(packnames))
from rpy2.robjects.packages import importr randomForestSRC = importr('randomForestSRC') from rpy2.robjects.methods import RS4Auto_Type import six
class rfsrc(six.with_metaclass(RS4Auto_Type)): rname = 'rfsrc' rpackagename = 'randomForestSRC'`