Skip to main content
Question

How to create a 2-column matrix of pairs given a unique column of attributes

  • August 22, 2019
  • 2 replies
  • 95 views

brian_
Contributor
Forum|alt.badge.img+4

I'm trying to figure out how to create the table (Output) from a single column table below.

In R, the function pair.matrix does what I need https://www.rdocumentation.org/packages/cape/versions/2.0.2/topics/pair.matrix

How can I replicate this?

Input

 

 

Output

 

 

 

idname

 

idnameid2name21apple

 

1apple1apple2banana

 

1apple2banana3carrot

 

1apple3carrot

 

 

 

2banana1apple

 

 

 

2banana2banana

 

 

 

2banana3carrot

 

 

 

3carrot1apple

 

 

 

3carrot2banana

 

 

 

3carrot3carrot
This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

2 replies

takashi
Celebrity
  • 7843 replies
  • August 22, 2019

Hi @brian_, a possible way is to use a FeatureMerger to merge unconditionally all Suppliers to every Requestor and save Suppliers attributes into a list attribute, then explode the features on the list with a ListExploder, as in:

Alternatively, the InlineQuerier (SQL), the PyhonCaller (Python scripting), the RCaller (R scripting), or the XMLXQueryExtractor (XQuery scripting) etc. could also be helpful.


brian_
Contributor
Forum|alt.badge.img+4
  • Author
  • Contributor
  • 4 replies
  • August 22, 2019

Hi @brian_, a possible way is to use a FeatureMerger to merge unconditionally all Suppliers to every Requestor and save Suppliers attributes into a list attribute, then explode the features on the list with a ListExploder, as in:

Alternatively, the InlineQuerier (SQL), the PyhonCaller (Python scripting), the RCaller (R scripting), or the XMLXQueryExtractor (XQuery scripting) etc. could also be helpful.

Perfect, thanks @takashi