Search code examples
matrixknime

How to convert a table in a matrix in KNIME?


Is it possible and if so, how to convert a table to a matrix?

My output table is structured as follows:

rowid   user   item   value
  0      x      A      10
  1      x      B      15
  2      x      C      0
  3      y      A      12
  4      y      B      17
  5      y      C      25 

My goal is to create a matrix in the following form:

rowid    A    B    C
  x      10   15   0
  y      12   17   25

Solution

  • Use a Pivoting node with the following settings:

    Group column(s) user

    Pivot column(s) item

    Manual Aggregation > Column value

    Advanced Settings > Column name: Pivot name

    You can leave the Aggregation set to First.

    Connect the Pivot table output to a RowID node with settings:

    Replace RowID with… checked

    New RowID column user

    Remove selected column checked

    screenshot