我在Python应用程序中使用PypeR,并希望从R脚本获取变量。
我的Python应用程序如下:
from pyper import *
r = R()
r.run("source('<PATH>/test.R')")
words = r.get("words", "No Variable found!", use_dict=False)
print (words)
test.R就像:
setwd("<PATH>")
words <- "Testword"
library(wordcloud)
如果我运行应用程序时未在test.RI中包含库,则得到响应“ Testword”。为什么要包含一个库(与哪个库无关),为什么找不到变量“ words”?我总是得到后备“找不到变量”。
我在Windows 10计算机上使用Python 3.5和R 3.2.2。
解决方案:必须首先加载依赖库(R自动执行此操作,而PypeR不这样做)。前任。:
library(NLP)
library(tm)
library(RColorBrewer)
library(wordcloud)
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句