如何使用包rPython?从R到Python输入参数
以下是一次天真的尝试
在script.py中:
print message剧本。R:
require(rPython)
text = "Hello World"
python.load("script.py", message=text)
Error in python.load("script.py", message = text) :
unused argument (message = text)发布于 2017-03-16 02:24:41
根据包的文档 (第5-6页),load方法:
此函数运行包含在文件中的Python代码。通常,该文件将包含通过python.call或此包中的其他函数调用的函数。
因此,Python中没有正在运行的脚本,而是只定义了带有返回对象的函数:
Python (script.py)
def print_message(msg):
return msgR (使用负载和调用)
require(rPython)
text = "Hello World"
python.load("script.py")
python.call("print_message", text)
#[1] "Hello World"https://stackoverflow.com/questions/42823115
复制相似问题