基本上
我设法在R
内执行了一个python脚本。但是,我不知道如何将这些值从python脚本返回到R
,并将这些值存储在R
中,尤其是在python脚本中有多个函数时。在
为了使这个过程成为可能,我应该向python脚本中添加什么?在
注意:假设我在开始时将参数python test.py arg1 arg2 arg3
从R传递给python。在
这是我写在下面的test.py
。在
#!/usr/bin/python
import sys
jd = sys.argv
def testing(jd):
print 'Number of arguments:', len(jd), 'arguments.'
print 'Argument List:', str(jd)
return jd
def testing2():
return 123123
testing(jd)
testing2()
我建议您在这里查看R/SPlus:http://www.omegahat.org/RSPython/
它支持在模块等中调用Python脚本和函数,并以SEXP(一种R通用数据类型)的形式返回值。在
不太清楚你想要什么。捕获简单的输出很容易:
相关问题 更多 >
编程相关推荐