简体   繁体   English

使用rpy2将.RData文件读入python

[英]Reading .RData files into python using rpy2

I am trying to read a .RData file into python using the rpy2 module. 我正在尝试使用rpy2模块将.RData文件读入python。 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. 我目前正在使用Windows 7,64位机器。 Please help. 请帮忙。

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. 在指定.RData文件的路径时,我使用标准的windows(“\\”)目录分隔符指定了路径,r.load()(显然)无法识别路径。 But when I use the "/" directory separator, the .rdata file was loaded successfully. 但是当我使用“/”目录分隔符时,.rdata文件已成功加载。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM