Rosie
Rosie

Reputation: 43

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.

Upvotes: 4

Views: 1817

Answers (2)

Brett Champion
Brett Champion

Reputation: 8567

Rotate[Grid[datasymbolgoeshere, Frame->All],90 Degree]

I like that the contents are still selectable.

Upvotes: 3

cah
cah

Reputation: 584

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]& ]

Upvotes: 7

Related Questions