【823】Python subprocess.call() 运行 R 代码
参考:How to Use R and Python Together? Try These 2 Packages
实现功能:在 Python 代码中运行 R 文件,得到结果再在 Python 里面操作!
import subprocess
res = subprocess.call("Rscript /Users/dradecic/Desktop/script.R", shell=True)
res
-
返回值为 0 的时候就是运行成功了!
-
可以把结果存储到具体的文件中,然后可以在 Python 里面调用。
-
参数可以以文件的形式传入到 R 代码中。