Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Reading .RData files into python using rpy2

I am trying to read a .RData file into python using the rpy2 module. Below is the code

>>> from  rpy2.robjects import r
>>> r.load("path to .rdata file")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\dell\WinPython-32bit-2.7.6.3\python-2.7.6\lib\site-packages\rpy2\robjects\functions.py", line 170, in __call__
return super(SignatureTranslatedFunction, self).__call__(*args, **kwargs)
File "C:\Users\dell\WinPython-32bit-2.7.6.3\python-2.7.6\lib\site-packages\rpy2\robjects\functions.py", line 100, in __call__
res = super(Function, self).__call__(*new_args, **new_kwargs)
rpy2.rinterface.RRuntimeError: Error in readChar(con, 5L, useBytes = TRUE) : cannot open the connection

I am currently using a windows 7, 64 bit machine. Please help.

like image 824
cyber_tooth Avatar asked Nov 09 '22 13:11

cyber_tooth


1 Answers

Ok, it seems I have understood the issue here.

whilst specifying the path to the .RData file, I specified the path using the standard windows ("\") directory separator which r.load() (obviously) didn't recognize the path. But when I use the "/" directory separator, the .rdata file was loaded successfully.

like image 75
cyber_tooth Avatar answered Nov 14 '22 22:11

cyber_tooth