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
Bug in
Rapidminerpartner
Member Posts: 35 Contributor II
Hello, everyone
I found a bug in "Execute R" operator
I am using R-3.6.0
Briefly, "Execute R" cannot compute mean function of R
I did
data[1,1] <- mean(data[3:5,4])
but it didn't work and why it didn't is written in the log file I attached
I believe it will not be able to compute var function either.
I attached the process and log files.
Please fix this problem for me
Thank you and have a nice day.
Best,
Tagged:
1
Best Answer
-
yyhuang Administrator, Employee-RapidMiner, RapidMiner Certified Analyst, RapidMiner Certified Expert, Member Posts: 364 RM Data ScientistHi @Rapidminerpartner
It seems that R's mean does not behave well with dataframes. One workaround is to convert the data to a regular matrix before taking the mean:data[1,1] <- mean(data.matrix(data[3:5,4]))
https://stackoverflow.com/questions/35485536/r-argument-is-not-numeric-or-logical-returning-na/52153758<?xml version="1.0" encoding="UTF-8"?><process version="9.4.000-BETA"> <context> <input/> <output/> <macros/> </context> <operator activated="true" class="process" compatibility="9.4.000-BETA" expanded="true" name="Process"> <parameter key="logverbosity" value="init"/> <parameter key="random_seed" value="2001"/> <parameter key="send_mail" value="never"/> <parameter key="notification_email" value=""/> <parameter key="process_duration_for_mail" value="30"/> <parameter key="encoding" value="SYSTEM"/> <process expanded="true"> <operator activated="true" breakpoints="after" class="retrieve" compatibility="9.4.000-BETA" expanded="true" height="68" name="Retrieve Iris" width="90" x="112" y="34"> <parameter key="repository_entry" value="//Samples/data/Iris"/> </operator> <operator activated="true" class="r_scripting:execute_r" compatibility="9.1.000" expanded="true" height="103" name="Execute R" width="90" x="313" 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) { print('Hello, world!') # output can be found in Log View data[1,1] <- mean(data.matrix(data[3:5,4])) # your code goes here # for example: data2 <- as.data.table(matrix(1:16,4,4)) # connect 2 output ports to see the results return(list(data,data2)) } "/> </operator> <connect from_op="Retrieve Iris" from_port="output" to_op="Execute R" to_port="input 1"/> <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>
6
Answers
Hello, yyhuang
Thank you for your help
It works now
Have a nice day!