我有一个JuPyter笔记本(Python),希望将参数列表传递到R程序(单独存储在同一目录中)。在R程序执行后,它将把结果传回JuPyter笔记本
我在macOS上
因此,我的问题如下:
command = "/Library/Frameworks/R.framework/Resources/bin/R"
script = "/Users/me/Desktop/rProgram.R"
args = [1,2,3] # some arguments to pass to R
cmd = [command, script] + args
p = subprocess.Popen(cmd, stdout = subprocess.PIPE, stderr = subprocess.PIPE)
results = p.communicate()
看来程序没有运行。如果我打印results
,我会得到:
ARGUMENT '/Users/me/Desktop/rProgram.R' __ignored__\n\n", b"Fatal error: you must specify '--save', '--no-save' or '--vanilla'\n")
发现上面我的目录中有一些错误。在Mac上,Rscript路径被指定为
/Library/Frameworks/R.framework/Versions/Current/Resources/Rscript
。我在上面的原始代码中使用的路径似乎不会运行R的实例x
是从rProgram.R脚本传回的必需参数相关问题 更多 >
编程相关推荐