how swap columns and rows
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?
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
Support Staff 1 Posted by john on 12 Mar, 2017 11:55 PM
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
Support Staff 2 Posted by john on 13 Mar, 2017 07:47 AM
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 Posted by denis.zaporozha... on 13 Mar, 2017 01:10 PM
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
Support Staff 4 Posted by john on 13 Mar, 2017 09:50 PM
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 Posted by denis.zaporozha... on 14 Mar, 2017 03:55 PM
Thank you very much!!
6 Posted by denis.zaporozha... on 14 Mar, 2017 11:57 PM
Thank you so much!
7 Posted by denis.zaporozha... on 15 Mar, 2017 10:41 AM
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 Posted by denis.zaporozha... on 15 Mar, 2017 10:43 AM
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 Posted by denis.zaporozha... on 16 Mar, 2017 07:31 AM
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.
Support Staff 10 Posted by john on 16 Mar, 2017 08:55 AM
This is a test comment. Denis said he was unable to post new comments to this thread.
Now I will try. Here goes...