Options

"Attribute types and assigning NA in R script"

tennenrishintennenrishin Member Posts: 177 Contributor II
edited June 2019 in Help
I'm not sure whether this is more of an R question or more of an RM question.

This process
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<process version="5.3.008">
 <context>
   <input/>
   <output/>
   <macros/>
 </context>
 <operator activated="true" class="process" compatibility="5.3.008" expanded="true" name="Process">
   <process expanded="true">
     <operator activated="true" class="generate_data_user_specification" compatibility="5.3.008" expanded="true" height="60" name="Generate Data by User Specification" width="90" x="179" y="165">
       <list key="attribute_values">
         <parameter key="T" value="date_parse_custom(&quot;2013.07.19 10:33:22&quot;,&quot;yyyy.MM.dd HH:mm:ss&quot;,&quot;en&quot;)"/>
       </list>
       <list key="set_additional_roles"/>
     </operator>
     <operator activated="true" class="date_to_nominal" compatibility="5.3.008" expanded="true" height="76" name="Date to Nominal" width="90" x="313" y="165">
       <parameter key="attribute_name" value="T"/>
       <parameter key="date_format" value="yyyy.MM.dd HH:mm:ss.SSS"/>
     </operator>
     <operator activated="true" class="r:execute_script_r" compatibility="5.3.000" expanded="true" height="76" name="Execute Script (R)" width="90" x="447" y="165">
       <parameter key="script" value="output &lt;- input&#10;output[,] &lt;- NA&#10;output[1,] &lt;- input[1,]&#10;# This is a minimal script to reproduce the problem.&#10;# In the actual script, the purpose of the first two lines are to allocate memory&#10;# and the data is transformed during the line-by-line assignment into the output.&#10;"/>
       <enumeration key="inputs">
         <parameter key="name_of_variable" value="input"/>
       </enumeration>
       <list key="results">
         <parameter key="output" value="Data Table"/>
       </list>
     </operator>
     <operator activated="true" class="nominal_to_date" compatibility="5.3.008" expanded="true" height="76" name="Nominal to Date" width="90" x="581" y="165">
       <parameter key="attribute_name" value="T"/>
       <parameter key="date_type" value="date_time"/>
       <parameter key="date_format" value="yyyy.MM.dd HH:mm:ss.SSS"/>
     </operator>
     <connect from_op="Generate Data by User Specification" from_port="output" to_op="Date to Nominal" to_port="example set input"/>
     <connect from_op="Date to Nominal" from_port="example set output" to_op="Execute Script (R)" to_port="input 1"/>
     <connect from_op="Execute Script (R)" from_port="output 1" to_op="Nominal to Date" to_port="example set input"/>
     <connect from_op="Nominal to Date" from_port="example set output" 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>
works if line 2 of the R script is commented out, but not if it isn't. Why is that, and how can I blank that dataframe without breaking the process. The minimalistic example seems quite silly but the background is hard to explain briefly.
Tagged:

Answers

  • Options
    MariusHelfMariusHelf RapidMiner Certified Expert, Member Posts: 1,869 Unicorn
    I am not an R expert, so I have to ask this question: does this script run in the R version that you have configured in RapidMiner? Is the expected output a simple copy of the input?

    Best regards,
    Marius
Sign In or Register to comment.