kogalur / randomForestSRC

DOCUMENTATION:
https://www.randomforestsrc.org/
GNU General Public License v3.0
117 stars 18 forks source link

randomForestSRC and generic functions - calling rfsrc from Python #22

Closed annette987 closed 5 years ago

annette987 commented 6 years ago

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'`

kogalur commented 5 years ago

Python is out of our scope. We are unable to comment on the issue, and suggest you contact users that are familiar with the R-Python interface.