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
Generate new dataframe with Execute R
Hi,
I am new to RM and tried to use Execute R to apply KS-test and return its result, which is a dataframe. When I ran my process, it shows "Process failed. Script terminated abnormally":
- 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:1004)
- com.rapidminer.operator.execution.SimpleUnitExecutor.execute(SimpleUnitExecutor.java:77)
- com.rapidminer.operator.ExecutionUnit$3.run(ExecutionUnit.java:812)
- com.rapidminer.operator.ExecutionUnit$3.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:1004)
- com.rapidminer.Process.execute(Process.java:1310)
- com.rapidminer.Process.run(Process.java:1285)
- com.rapidminer.Process.run(Process.java:1176)
- com.rapidminer.Process.run(Process.java:1129)
- com.rapidminer.Process.run(Process.java:1124)
- com.rapidminer.Process.run(Process.java:1114)
- com.rapidminer.gui.ProcessThread.run(ProcessThread.java:65)
I can run the example code without similar problem and if I deleted the last two lines - "ks.table<-as.data.table(ks.table)
return(ks.table)". It is fine as well...
Here is my XML.:
<?xml version="1.0" encoding="UTF-8"?><process version="8.1.000">
<context>
<input/>
<output/>
<macros/>
</context>
<operator activated="true" class="process" compatibility="8.1.000" expanded="true" name="Process">
<process expanded="true">
<operator activated="true" class="retrieve" compatibility="8.1.000" expanded="true" height="68" name="Retrieve Golf" width="90" x="45" y="34">
<parameter key="repository_entry" value="//Samples/data/Golf"/>
</operator>
<operator activated="true" class="r_scripting:execute_r" compatibility="8.1.000" expanded="true" height="82" name="Execute R (2)" width="90" x="246" y="34">
<parameter key="script" value="# 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) { library(dplyr) library(data.table) columnname<-c() ###Save the column name and label name: for(i in seq(along = metaData$data)){ 	columnname<-c(columnname, names(metaData$data)[i]) 	 	if (metaData$data[[i]]$role == 'label'){ 	labelname<- names(metaData$data)[i] 	} } ### apply filter based on the label: expyes<-lazyeval::interp(quote(x == y), x=as.name(labelname), y = "yes") expno<-lazyeval::interp(quote(x == y), x=as.name(labelname), y = "no") yes<- filter_(data, expyes) no<- filter_(data, expno) ks.table<-data.frame() for(i in seq(along = metaData$data)){ 	if ((metaData$data[[i]]$role == 'label') | (metaData$data[[i]]$type != "Integer") ) next 	 	cyes<-select(yes, select = names(metaData$data)[i]) 	cno<- select(no, select = names(metaData$data)[i]) 	ks<-ks.test(cyes, cno) 	row<-data.frame(names(metaData$data)[i], ks$statistic,ks$p.value) 	print(as.character(row)) 	ks.table<-rbind(ks.table, row) } ks.table<-as.data.table(ks.table) return(ks.table) } "/>
</operator>
<connect from_op="Retrieve Golf" from_port="output" to_op="Execute R (2)" to_port="input 1"/>
<connect from_op="Execute R (2)" from_port="output 1" to_port="result 1"/>
<portSpacing port="source_input 1" spacing="0"/>
<portSpacing port="source_input 2" spacing="0"/>
<portSpacing port="sink_result 1" spacing="0"/>
<portSpacing port="sink_result 2" spacing="0"/>
</process>
</operator>
</process>
Does anyone have idea why it happens? Thanks for help!
Tagged:
0
Best Answer
-
earmijo Member Posts: 271 Unicorn
In the R code you keep making reference to the object metaData that has never been defined. Try the code in R first and see if it runs.
1
Answers
Thank you @earmijo! It was my coding problem... Wrong data types have been delivered to ks.test() function.