I have this function in R and I want to call it in python. I am planning to assign the data which has been manipulated in python to the R function to do further analysis on it. I also need to have the data back to python after the function did the analysis. I know about rpy2 and I used this command
robjects.r('''source('mycode.R')''')
r_test_function = robjects.globalenv['myFunction']
I get this error:
/usr/local/lib/python2.7/dist-packages/rpy2/rinterface/init.py:186: RRuntimeWarning: Error in file(filename, "r", encoding = encoding) :
cannot open the connectionwarnings.warn(x, RRuntimeWarning) /usr/local/lib/python2.7/dist-packages/rpy2/rinterface/init.py:186: RRuntimeWarning: In addition: warnings.warn(x, RRuntimeWarning) /usr/local/lib/python2.7/dist-packages/rpy2/rinterface/init.py:186: RRuntimeWarning: Warning message:
warnings.warn(x, RRuntimeWarning) /usr/local/lib/python2.7/dist-packages/rpy2/rinterface/init.py:186: RRuntimeWarning: In file(filename, "r", encoding = encoding) :
warnings.warn(x, RRuntimeWarning) /usr/local/lib/python2.7/dist-packages/rpy2/rinterface/init.py:186: RRuntimeWarning:warnings.warn(x, RRuntimeWarning) /usr/local/lib/python2.7/dist-packages/rpy2/rinterface/init.py:186: RRuntimeWarning: cannot open file 'mycode.R': No such file or directory
warnings.warn(x, RRuntimeWarning) Info | ____________________________________________________________________________________________________| Error | Termination with exception status| Error
I used the sys.path.append('thePath')
for the directory containing the function. Can someone please help me about this? I have searched a lot about the topic but I could not find anything in my case. Also is what I explained above practical with rpy2?
Thank you,