0

I have one function in R. I want to use that function in python.But I am getting error while passing arguments.

Calling R function from python referenced from calling a R function from python code with passing arguments this site.

I have tried like below with my exisiting function

path=""
actual_values= data['col1']
predicted_values = data['col2']
def function1(input1,output):
    r=ro.r
    r.source(path+"script.R")
    p=r.metrics_fun(input1,output) # function name in the R is metrics_fun
    return p
output_df = function1(actual_values,predicted_values)

I am getting error like below

NotImplementedError: Conversion 'py2rpy' not defined for objects of type '<class 'pandas.core.series.Series'>'

Please, help me to find solution for this.

Navya
  • 307
  • 3
  • 15
  • Does this answer your question? [Python Pandas to R dataframe](https://stackoverflow.com/questions/24094476/python-pandas-to-r-dataframe) – Rishabh Kumar Feb 24 '21 at 09:00
  • It is not about converting python dataframe to R data frame. I want to use the function which is defined in R script.While I am passing pandas dataframe columns it is giving the error while using above method. Error:```module 'base' has no attribute 'fun_name'``` . – Navya Feb 24 '21 at 10:01
  • It is easier to help when the example is complete (self-contained). Here there is no indication about what type are the objects passed when calling R, or what Python modules are imported. Also, did you check the rpy2 documentation? For example, https://rpy2.github.io/doc/v3.4.x/html/pandas.html – lgautier Feb 28 '21 at 15:36

0 Answers0