有没有一种简单的方法可以在R和Python之间传递数据帧?

时间:2016-09-23 04:05:20

标签: python r

我正在寻找一种在R和Python之间传递数据帧的方法,而不是编写csv文件。

我正在使用R中的一个包,我希望使用Python来处理更繁重的计算。

我目前正在使用system {,从source

找到

这不是我的计划,但这里是R的基本想法。

run_splitstr.R

command ="python“

Note the single + double quotes in the string (needed if paths have spaces)
path2script='"path/to your script/splitstr.py"'

Build up args in a vector
string ="3523462---12413415---4577678---7967956---5456439"
pattern ="---"
args = c(string, pattern)

# Add path to script as first arg
allArgs = c(path2script, args)

output = system2(command, args=allArgs, stdout=TRUE)

print(paste("The Substrings are:\n", output))

这在我的机器上运行良好,但我必须将数据帧作为Python和R之间的单独csv文件传递,我担心这不能被接受以使其成为一个包。

Windows系统有没有比这更好的方法?或者这整个想法是徒劳的。

谢谢!

0 个答案:

没有答案
相关问题