RapidMiner

Problem with running R code in the application

SOLVED
Wisdom logo Registration now open for RapidMiner Wisdom Americas | New Orleans | October 10-12, 2018   Learn More
Unicorn
Unicorn

Re: Problem with running R code in the application

@jozeftomas_2020 your going to have to check if RapidMiner can access those packages. 

Regards,
Thomas

Blog: Neural Market Trends

RapidMiner Tutorial Videos here!
Contributor II jozeftomas_2020
Contributor II

Re: Problem with running R code in the application

Hello
How and by what steps can I do?
May you tell me?
Thankful

 

Unicorn
Unicorn

Re: Problem with running R code in the application

@jozeftomas_2020 R loads it's packages into folders on your computer. You should check if it's loading them into your user account where RM Studio can access. Then I would just take one Execute R operator and the type in "require(some library)" and run the process. If it doesn't break or complain, then RM Studio can access the library. Repeat till all  your libraries are able to load. If one fails, then you'll need to open up the R console and install it in the right directory where RM can find it. 

Regards,
Thomas

Blog: Neural Market Trends

RapidMiner Tutorial Videos here!
Contributor II jozeftomas_2020
Contributor II

Re: Problem with running R code in the application

Hi Dear Professor @Thomas_Ott
In this case, I Novice and beginner.
Can you tell me what steps to take?
Sorry to ask
With respect

Unicorn
Unicorn

Re: Problem with running R code in the application

@jozeftomas_2020 in your R console, type the following:

.libPaths()

 That will tell you where the packages are being stored. Check that directory (or directories) to make sure the libraries are installed there. Then check where RapidMIner is calling the Rscript.exe from (see your RM Studio preferences). It could be that Rscript.exe is calling from a different R library. 

Regards,
Thomas

Blog: Neural Market Trends

RapidMiner Tutorial Videos here!
Contributor II jozeftomas_2020
Contributor II

Re: Problem with running R code in the application

 

Hello
Thank you very much for your help.
I gave this path

 

C:/Program Files/R/R-3.4.3/bin/Rscript.exe


I put this code in the script to draw the word cloud, but it did not work
If my RAM is high. And how many times I tried. But this error every time.
How to tell the code in the script on my data and on the third column of that text?

r1.JPGr2.JPG


Can I help me again?
Thank you
With respect

 

 

library("tm")
library("SnowballC")
library("wordcloud")
library("RColorBrewer")

# Read the text file from internet
filePath <- "C:/pfull_1.csv"
text <- readLines(filePath)
docs <- Corpus(VectorSource(text))
inspect(docs)
toSpace <- content_transformer(function (x , pattern ) gsub(pattern, " ", x))
docs <- tm_map(docs, toSpace, "/")
docs <- tm_map(docs, toSpace, "@")
docs <- tm_map(docs, toSpace, "\\|")
# Convert the text to lower case
docs <- tm_map(docs, content_transformer(tolower))
# Remove numbers
docs <- tm_map(docs, removeNumbers)
# Remove english common stopwords
docs <- tm_map(docs, removeWords, stopwords("english"))
# Remove your own stop word
# specify your stopwords as a character vector
docs <- tm_map(docs, removeWords, c("blabla1", "blabla2"))
# Remove punctuations
docs <- tm_map(docs, removePunctuation)
# Eliminate extra white spaces
docs <- tm_map(docs, stripWhitespace)
# Text stemming
# docs <- tm_map(docs, stemDocument)
dtm <- TermDocumentMatrix(docs)
m <- as.matrix(dtm)
v <- sort(rowSums(m),decreasing=TRUE)
d <- data.frame(word = names(v),freq=v)
head(d, 10)
set.seed(1234)
wordcloud(words = d$word, freq = d$freq, min.freq = 1,
max.words=200, random.order=FALSE, rot.per=0.35,
colors=brewer.pal(8, "Dark2"))

Unicorn
Unicorn

Re: Problem with running R code in the application

@jozeftomas_2020 i think you have to write out wordcloud image. right after 'set.seed(1234)' try adding

 

png("wordcloud.png", width=1280,height=800)
wordcloud(words = d$word, freq = d$freq, min.freq = 1,
max.words=200, random.order=FALSE, rot.per=0.35,
colors=brewer.pal(8, "Dark2"))
dev.off()

 You might have to path wordcloud.png to some directory or it will save it to the default R directory somewhere.

Regards,
Thomas

Blog: Neural Market Trends

RapidMiner Tutorial Videos here!
Contributor II jozeftomas_2020
Contributor II

Re: Problem with running R code in the application

Hello dear Professor @Thomas_Ott
I wrote this

png ("D: /wordcloud.png", width = 1280, height = 800)
wordcloud (words = d $ word, freq = d $ freq, min.freq = 1,
  max.words = 200, random.order = FALSE, rot.per = 0.35,
  colors = brewer.pal (8, "dark2"))
dev.off ()


But again the same error went up.
Please tell me what is the problem?
Is it possible to send me the process that was implemented?
Thank you very much for your help

 

And I'm going to run the code on my data
I loaded the data and then with the 'select attribute' operator I chose my text column and then I connected to the 'excute R' operator, but the same error occurred again.
Could you guide how to provide data and text columns to run the code?
Sorry sorry i'm asking

 


With respect

Contributor II jozeftomas_2020
Contributor II

Re: Problem with running R code in the application

hello

sorry..

please help me..

Smiley Sad

No matter how hard I try. It's not good. And I am not able to draw the words of the cloud

Highlighted
Unicorn
Unicorn
Solution

Re: Problem with running R code in the application

@jozeftomas_2020 Here you go. This is simplified using the Text Processing extension in RapidMiner. I just used a bit of R code to draw the word cloud.

wordcloud.png

 

 

 

 

<?xml version="1.0" encoding="UTF-8"?><process version="8.2.001">
  <context>
    <input/>
    <output/>
    <macros/>
  </context>
  <operator activated="true" class="process" compatibility="8.2.001" expanded="true" name="Process">
    <process expanded="true">
      <operator activated="true" class="social_media:search_twitter" compatibility="8.1.000" expanded="true" height="68" name="Search Twitter" width="90" x="45" y="34">
        <parameter key="connection" value="Twitter"/>
        <parameter key="query" value="rapidminer"/>
      </operator>
      <operator activated="true" class="select_attributes" compatibility="8.2.001" expanded="true" height="82" name="Select Attributes" width="90" x="179" y="34">
        <parameter key="attribute_filter_type" value="single"/>
        <parameter key="attribute" value="Text"/>
      </operator>
      <operator activated="true" class="nominal_to_text" compatibility="8.2.001" expanded="true" height="82" name="Nominal to Text" width="90" x="313" y="34">
        <parameter key="attribute_filter_type" value="single"/>
        <parameter key="attribute" value="Text"/>
      </operator>
      <operator activated="true" class="text:process_document_from_data" compatibility="8.1.000" expanded="true" height="82" name="Process Documents from Data" width="90" x="447" y="34">
        <parameter key="prune_method" value="percentual"/>
        <list key="specify_weights"/>
        <process expanded="true">
          <operator activated="true" class="text:tokenize" compatibility="8.1.000" expanded="true" height="68" name="Tokenize" width="90" x="112" y="34"/>
          <connect from_port="document" to_op="Tokenize" to_port="document"/>
          <connect from_op="Tokenize" from_port="document" to_port="document 1"/>
          <portSpacing port="source_document" spacing="0"/>
          <portSpacing port="sink_document 1" spacing="0"/>
          <portSpacing port="sink_document 2" spacing="0"/>
        </process>
      </operator>
      <operator activated="true" class="text:wordlist_to_data" compatibility="8.1.000" expanded="true" height="82" name="WordList to Data" width="90" x="581" y="85"/>
      <operator activated="true" class="select_attributes" compatibility="8.2.001" expanded="true" height="82" name="Select Attributes (2)" width="90" x="715" y="85">
        <parameter key="attribute_filter_type" value="subset"/>
        <parameter key="attributes" value="word|total"/>
      </operator>
      <operator activated="true" class="r_scripting:execute_r" compatibility="8.1.000" expanded="true" height="82" name="Execute R" width="90" x="849" y="85">
        <parameter key="script" value="# rm_main is a mandatory function, &#10;# the number of arguments has to be the number of input ports (can be none)&#10;rm_main = function(data)&#10;{&#10;&#9;library(&quot;wordcloud&quot;)&#10;&#9;library(&quot;RColorBrewer&quot;)&#10;&#9;&#10;&#9;png(&quot;C:\\Users\\TomOtt\\Desktop\\wordcloud.png&quot;, width=1280,height=800)&#10;&#9;wordcloud(words = data$word, freq = data$total, min.freq = 1, max.words=200, random.order=FALSE, rot.per=0.35, colors=brewer.pal(8, &quot;Dark2&quot;))&#10;&#9;dev.off()&#10;&#9;&#10;&#9;return (data)&#10;}&#10;"/>
      </operator>
      <connect from_op="Search Twitter" from_port="output" to_op="Select Attributes" to_port="example set input"/>
      <connect from_op="Select Attributes" from_port="example set output" to_op="Nominal to Text" to_port="example set input"/>
      <connect from_op="Nominal to Text" from_port="example set output" to_op="Process Documents from Data" to_port="example set"/>
      <connect from_op="Process Documents from Data" from_port="word list" to_op="WordList to Data" to_port="word list"/>
      <connect from_op="WordList to Data" from_port="example set" to_op="Select Attributes (2)" to_port="example set input"/>
      <connect from_op="Select Attributes (2)" from_port="example set output" to_op="Execute R" to_port="input 1"/>
      <connect from_op="Execute R" from_port="output 1" to_port="result 1"/>
      <portSpacing port="source_input 1" spacing="0"/>
      <portSpacing port="sink_result 1" spacing="0"/>
      <portSpacing port="sink_result 2" spacing="0"/>
    </process>
  </operator>
</process>
Regards,
Thomas

Blog: Neural Market Trends

RapidMiner Tutorial Videos here!