Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I flip the orientation of a grid?

I'm just doing a simple Grid[datasymbolgoeshere, Frame->All] command. It's taking a list of ID numbers (e.g., {11282,11281,11280}) and placing each one in its own column. I just want to flip the orientation so all strings in a single list are placed in the same column (individual rows, one on top of another), and the next list of strings goes in the second column.

like image 288
Rosie Avatar asked Oct 18 '25 23:10

Rosie


1 Answers

Sounds like you want

Grid[Transpose[datasymbolgoeshere],Frame->All]

Edit -- by the way Grid assumes a multidimensional list. It won't complain if you call, eg Grid[{1,2}] but Mma cannot simplify that expression and just returns it as-is. Grid will work with a ragged array, but Transpose will complain, so you will need to pad the elements of datasymbolgoeshere to make your array rectangular.

Putting it all together, something like this should work on most inputs

With[ { maxLength=Length/@data//Max }, PadRight[#,maxLength,""]&/@data//Grid[#,Frame->All]& ]

like image 173
cah Avatar answered Oct 22 '25 06:10

cah



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!