Can rapid transfer table like that?

fvbnju765r
fvbnju765r New Altair Community Member
edited November 5 in Community Q&A
for example
---------------
ID-shopping
1-egg
2-meat
3-vegetable

transfer it to
-----------------
ID-egg-meat-vegetable
1-t-f-f
2-f-t-f
3-f-f-t

can rapid do this kind transfer?
(I used to use IBM spss module to do that )

Tagged:

Answers

  • Hello

    You can use the Pivot operator plus some gymnastics.

    Here's an example
    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <process version="5.3.015">
      <context>
        <input/>
        <output/>
        <macros/>
      </context>
      <operator activated="true" class="process" compatibility="5.3.015" expanded="true" name="Process">
        <process expanded="true">
          <operator activated="true" class="subprocess" compatibility="5.3.015" expanded="true" height="76" name="Subprocess" width="90" x="45" y="75">
            <process expanded="true">
              <operator activated="true" class="generate_data_user_specification" compatibility="5.3.015" expanded="true" height="60" name="Generate Data by User Specification" width="90" x="45" y="30">
                <list key="attribute_values">
                  <parameter key="id" value="1"/>
                  <parameter key="shopping" value="&quot;egg&quot;"/>
                </list>
                <list key="set_additional_roles"/>
              </operator>
              <operator activated="true" class="generate_data_user_specification" compatibility="5.3.015" expanded="true" height="60" name="Generate Data by User Specification (2)" width="90" x="45" y="120">
                <list key="attribute_values">
                  <parameter key="id" value="2"/>
                  <parameter key="shopping" value="&quot;meat&quot;"/>
                </list>
                <list key="set_additional_roles"/>
              </operator>
              <operator activated="true" class="generate_data_user_specification" compatibility="5.3.015" expanded="true" height="60" name="Generate Data by User Specification (3)" width="90" x="45" y="210">
                <list key="attribute_values">
                  <parameter key="id" value="3"/>
                  <parameter key="shopping" value="&quot;vegetable&quot;"/>
                </list>
                <list key="set_additional_roles"/>
              </operator>
              <operator activated="true" class="append" compatibility="5.3.015" expanded="true" height="112" name="Append" width="90" x="246" y="75"/>
              <operator activated="true" class="generate_attributes" compatibility="5.3.015" expanded="true" height="76" name="Generate Attributes" width="90" x="380" y="75">
                <list key="function_descriptions">
                  <parameter key="quantity" value="1"/>
                </list>
              </operator>
              <connect from_op="Generate Data by User Specification" from_port="output" to_op="Append" to_port="example set 1"/>
              <connect from_op="Generate Data by User Specification (2)" from_port="output" to_op="Append" to_port="example set 2"/>
              <connect from_op="Generate Data by User Specification (3)" from_port="output" to_op="Append" to_port="example set 3"/>
              <connect from_op="Append" from_port="merged set" to_op="Generate Attributes" to_port="example set input"/>
              <connect from_op="Generate Attributes" from_port="example set output" to_port="out 1"/>
              <portSpacing port="source_in 1" spacing="0"/>
              <portSpacing port="sink_out 1" spacing="0"/>
              <portSpacing port="sink_out 2" spacing="0"/>
            </process>
          </operator>
          <operator activated="true" class="pivot" compatibility="5.3.015" expanded="true" height="76" name="Pivot" width="90" x="179" y="75">
            <parameter key="group_attribute" value="id"/>
            <parameter key="index_attribute" value="shopping"/>
            <parameter key="consider_weights" value="false"/>
            <parameter key="skip_constant_attributes" value="false"/>
          </operator>
          <operator activated="true" class="rename_by_replacing" compatibility="5.3.015" expanded="true" height="76" name="Rename by Replacing" width="90" x="313" y="75">
            <parameter key="replace_what" value="quantity_(.*)"/>
            <parameter key="replace_by" value="$1"/>
          </operator>
          <operator activated="true" class="replace_missing_values" compatibility="5.3.015" expanded="true" height="94" name="Replace Missing Values" width="90" x="447" y="75">
            <parameter key="default" value="value"/>
            <list key="columns"/>
            <parameter key="replenishment_value" value="0"/>
          </operator>
          <operator activated="true" class="numerical_to_binominal" compatibility="5.3.015" expanded="true" height="76" name="Numerical to Binominal" width="90" x="581" y="75">
            <parameter key="attribute_filter_type" value="subset"/>
            <parameter key="attributes" value="|id"/>
            <parameter key="invert_selection" value="true"/>
          </operator>
          <connect from_op="Subprocess" from_port="out 1" to_op="Pivot" to_port="example set input"/>
          <connect from_op="Pivot" from_port="example set output" to_op="Rename by Replacing" to_port="example set input"/>
          <connect from_op="Rename by Replacing" from_port="example set output" to_op="Replace Missing Values" to_port="example set input"/>
          <connect from_op="Replace Missing Values" from_port="example set output" to_op="Numerical to Binominal" to_port="example set input"/>
          <connect from_op="Numerical to Binominal" 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>

    regards

    Andrew
  • fvbnju765r
    fvbnju765r New Altair Community Member
    thanks,
    I just feel some thing like IBM spss module has a tool to do this kind of transfer by no typing code
    why rapid do it so difficult?