PypeR fails if R using library(tm)

427 Views Asked by At

I am using PypeR in my Python Application and want to get a variable from a R script.

My Python Application is as follows:

from pyper import *
r = R()
r.run("source('<PATH>/test.R')")
words = r.get("words", "No Variable found!", use_dict=False)
print (words)

The test.R is just like:

setwd("<PATH>")
words <- "Testword"
library(wordcloud)

If I run the application without including a library in test.R I get the response "Testword". Why if I include a library (doesn't matter which one), no variable "words" is found? I always get the fallback "No variable found".

I am using Python 3.5 and R 3.2.2 on my Windows 10 machine.

1

There are 1 best solutions below

0
On BEST ANSWER

Solution: necessary to load dependent librarys first (R does this automatically, PypeR not). Ex.:

library(NLP)
library(tm)

library(RColorBrewer)
library(wordcloud)