The Altair Community is migrating to a new platform to provide a better experience for you. In preparation for the migration, the Altair Community is on read-only mode from October 28 - November 6, 2024. Technical support via cases will continue to work as is. For any urgent requests from Students/Faculty members, please submit the form linked here

R script terminated anormally

kcallankcallan Member Posts: 4 Learner III
edited December 2018 in Help

I am trying to run a simple R script to gather data using the dplyr package, which is installed in my R sintallation I get the message that the script terminated abnormally. The full error:

Exception: com.rapidminer.operator.OperatorException
Message: Script terminated abnormally.
Stack trace:

com.rapidminer.extension.rscripting.operator.scripting.AbstractScriptRunner.run(AbstractScriptRunner.java:166)
com.rapidminer.extension.rscripting.operator.scripting.AbstractScriptingLanguageOperator.doWork(AbstractScriptingLanguageOperator.java:90)
com.rapidminer.extension.rscripting.operator.scripting.r.RScriptingOperator.doWork(RScriptingOperator.java:73)
com.rapidminer.operator.Operator.execute(Operator.java:1025)
com.rapidminer.operator.execution.SimpleUnitExecutor.execute(SimpleUnitExecutor.java:77)
com.rapidminer.operator.ExecutionUnit$2.run(ExecutionUnit.java:812)
com.rapidminer.operator.ExecutionUnit$2.run(ExecutionUnit.java:807)
java.security.AccessController.doPrivileged(Native Method)
com.rapidminer.operator.ExecutionUnit.execute(ExecutionUnit.java:807)
com.rapidminer.operator.OperatorChain.doWork(OperatorChain.java:428)
com.rapidminer.operator.Operator.execute(Operator.java:1025)
com.rapidminer.Process.execute(Process.java:1315)
com.rapidminer.Process.run(Process.java:1290)
com.rapidminer.Process.run(Process.java:1181)
com.rapidminer.Process.run(Process.java:1134)
com.rapidminer.Process.run(Process.java:1129)
com.rapidminer.Process.run(Process.java:1119)
com.rapidminer.gui.ProcessThread.run(ProcessThread.java:65)

R script:

 

# rm_main is a mandatory function, 
# the number of arguments has to be the number of input ports (can be none)
rm_main = function(data)
{


# your code goes here
library(dplyr)
data_long <- gather(data, stage, avg_weeks, average(lodgedCouncilToCertification_Weeks): average(SOCToRegistration_Weeks), factor_key=TRUE)

# connect output port to see the results
return(data_long)
}

 

Tagged:

Best Answer

  • yyhuangyyhuang Administrator, Employee-RapidMiner, RapidMiner Certified Analyst, RapidMiner Certified Expert, Member Posts: 364 RM Data Scientist
    Solution Accepted

    Hi @kcallan,

     

    gather() function may return a regular table or return a tibble table, which is a data frame with some minor variations from the base class

    For tibble, if you need to view the result table in result view, it needs to be converted as data table.

    I donot have your input data, but here is an exmple integration

    <?xml version="1.0" encoding="UTF-8"?><process version="9.0.000-BETA4">
    <context>
    <input/>
    <output/>
    <macros/>
    </context>
    <operator activated="true" class="process" compatibility="9.0.000-BETA4" expanded="true" name="Process">
    <process expanded="true">
    <operator activated="true" class="r_scripting:execute_r" compatibility="8.1.000" expanded="true" height="103" name="Execute R" width="90" x="179" y="30">
    <parameter key="script" value="rm_main = function()&#10;{&#10;&#9;library(tidyr)&#10;&#9;library(dplyr)&#10;&#9;stocks &lt;- tibble(&#10; &#9;time = as.Date('2009-01-01') + 0:9,&#10;&#9;X = rnorm(10, 0, 1),&#10; &#9;Y = rnorm(10, 0, 2),&#10; &#9;Z = rnorm(10, 0, 4)&#10;)&#10;&#10;&#9;result &lt;- as.data.frame(tib &lt;- gather(stocks, stock, price, -time))&#10;&#9;result$time &lt;- as.character(result$time)&#10;&#9;return(list(tib,result))&#10; &#10;}&#10;"/>
    </operator>
    <connect from_op="Execute R" from_port="output 1" to_port="result 1"/>
    <connect from_op="Execute R" from_port="output 2" to_port="result 2"/>
    <portSpacing port="source_input 1" spacing="0"/>
    <portSpacing port="sink_result 1" spacing="0"/>
    <portSpacing port="sink_result 2" spacing="0"/>
    <portSpacing port="sink_result 3" spacing="0"/>
    </process>
    </operator>
    </process>

    gather.PNG

Answers

  • SGolbertSGolbert RapidMiner Certified Analyst, Member Posts: 344 Unicorn

    I would like to add that where you print something in any of the script operators, it gets printed to the process log. I think it is one of the best ways to debug from RapidMiner studio.

     

    Regards,

    Sebastian

Sign In or Register to comment.