how swap columns and rows

denis.zaporozhan's Avatar

denis.zaporozhan

12 Mar, 2017 10:23 PM

Sometimes I need to swap the rows and columns in a table.
In order to render the data visualization "on the other side" )
Tell me how to do this in Nodebox?

  1. Support Staff 1 Posted by john on 12 Mar, 2017 11:55 PM

    john's Avatar

    Hi Denis,

    Good question. If you will post your csv table I will write you a subnetwork to transpose it.

    NodeBox tables, which are actually lists of zipmaps, need to have column headers. To transpose a table you will probably want to use the values in your first column, currently used as row headers, to be turned in to column headers. If that's how your table is organized this is fairly straightforward.

    John

  2. Support Staff 2 Posted by john on 13 Mar, 2017 07:47 AM

    john's Avatar

    Denis,

    Assuming your table is organized the way I described, the attached transpose subnetwork should do what you want.

    Just feed your table (or any node that resolves into a table) into the transpose node and it will switch the rows and columns. See attached screenshots.

    Transpose works by using the key node to determine the current column headers and uses the first of these to create a list of the current row headers. It then uses the assemble subnetwork to build one row for each current column.

    Enjoy!

  3. 3 Posted by denis.zaporozha... on 13 Mar, 2017 01:10 PM

    denis.zaporozhan's Avatar

    Many thanks, John!
    I teach the design of infographics on the course Data Journalism at the Higher School of Economics in Moscow. Nodebox is convenient as a didactic tool (Nodebox visually shows students what transformations occur with data)
    Here, for example, we differently visualize a small data set:
    Flow diagram (columns in the table by years)
    Line graph (in columns - countries)
    (Attached files)
    All pictures are completely made in Nodebox :)
    The task for students is to do the most complete information blocks without switching to other tools)
    Only in Nodebox

  4. Support Staff 4 Posted by john on 13 Mar, 2017 09:50 PM

    john's Avatar

    Denis,

    These visualizations are beautiful. I agree that NodeBox is a great didactic way to teach the art of visualization. That's what I love about it - I can see each step of the transformation.

    By the way, after a good night's sleep I realized the network I sent you yesterday works fine, but has 3 unnecessary nodes. There is no reason to slice up the list of column headers and put it back together again. Silly me. Without those nodes the transpose subnetwork is even simpler.

    Revised node and screenshot attached.

    John

  5. 5 Posted by denis.zaporozha... on 14 Mar, 2017 03:55 PM

    denis.zaporozhan's Avatar

    Thank you very much!!

  6. 6 Posted by denis.zaporozha... on 14 Mar, 2017 11:57 PM

    denis.zaporozhan's Avatar

    Thank you so much!

  7. 7 Posted by denis.zaporozha... on 15 Mar, 2017 10:41 AM

    denis.zaporozhan's Avatar

    I can not add a new comment in this thread.
    The message disappears(

    Hello, John! For some reason I can use the created by you node, but I can not repeat it myself. It seems that the nodes on the subnet and outside of it work differently. At some point even your network stops working (apparently this is a bug of the program) helps to move the file. Can not be repaired) but if copied to another project, the node works as it should.

  8. 8 Posted by denis.zaporozha... on 15 Mar, 2017 10:43 AM

    denis.zaporozhan's Avatar

    Hi, John! For some reason I can use the created by you node, but I can not repeat it myself. It seems that the nodes on the subnet and outside of it work differently. At some point even your network stops working (apparently this is a bug of the program) helps to move the file. Can not be repaired) but if copied to another project, the node works as it should.

  9. 9 Posted by denis.zaporozha... on 16 Mar, 2017 07:31 AM

    denis.zaporozhan's Avatar

    Hello, John!
    For some reason I can use the created by you node, but I can not repeat it myself. It seems that the nodes on the subnet and outside of it work differently. At some point even your network stops working (apparently this is a bug of the program) helps to move the file. Can not be repaired) but if copied to another project, the node works as it should.

  10. Support Staff 10 Posted by john on 16 Mar, 2017 08:55 AM

    john's Avatar

    This is a test comment. Denis said he was unable to post new comments to this thread.

    Now I will try. Here goes...

Reply to this discussion

Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

Attaching KB article:

»

Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac

Recent Discussions

16 Feb, 2025 11:13 AM
15 Feb, 2025 12:51 PM
06 Feb, 2025 01:37 AM
04 Feb, 2025 06:32 AM
04 Feb, 2025 05:04 AM

 

30 Jan, 2025 09:31 AM
30 Jan, 2025 09:08 AM
30 Jan, 2025 08:40 AM
24 Jan, 2025 07:50 AM
22 Jan, 2025 11:42 PM
21 Jan, 2025 09:43 AM