how to create/edit macro in execute R?
juju
New Altair Community Member
Answers
-
I figured out a way:
generate something in R, and make it the output of R by returning data.frame(x = something)
And send this output data frame into a 'extract macro' process, and extract column x, first row - the content is something.
Code:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<process version="6.4.000">
<context>
<input/>
<output/>
<macros/>
</context>
<operator activated="true" class="process" compatibility="6.4.000" expanded="true" name="Process">
<process expanded="true">
<operator activated="true" class="r_scripting:execute_r" compatibility="6.4.000" expanded="true" height="76" name="Execute R" width="90" x="112" y="30">
<parameter key="script" value=" rm_main = function(){ 	data.frame(x = 50) } "/>
</operator>
<operator activated="true" class="extract_macro" compatibility="6.4.000" expanded="true" height="60" name="Extract Macro" width="90" x="246" y="30">
<parameter key="macro" value="nn"/>
<parameter key="macro_type" value="data_value"/>
<parameter key="attribute_name" value="x"/>
<parameter key="example_index" value="1"/>
<list key="additional_macros"/>
</operator>
<operator activated="true" class="r_scripting:execute_r" compatibility="6.4.000" expanded="true" height="76" name="Execute R (2)" width="90" x="447" y="30">
<parameter key="script" value="rm_main = function(nn = %{nn}){ 	 	print(nn*2) 	 	data.frame(new = nn*2) } "/>
</operator>
<connect from_op="Execute R" from_port="output 1" to_op="Extract Macro" to_port="example set"/>
<connect from_op="Execute R (2)" 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>0