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.
Asked
Active
Viewed 1,722 times
3

Brian Tompsett - 汤莱恩
- 5,753
- 72
- 57
- 129

Rosie
- 33
- 3
-
3if you give an example of what is in datasymbolgoeshere it'll be easier to provide an answer! – acl Jun 24 '11 at 18:09
2 Answers
6
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]&
]

cah
- 574
- 3
- 4
-
2It might also be useful to bear in mind that [Flatten](http://reference.wolfram.com/mathematica/ref/Flatten.html) can do a Transpose of a ragged array. (see the example under 'Applications' in `Flatten` Help). For example `Grid[Flatten[{{11282, 11281, 11280}, {12282, 12281, 12280}, {13282, 13281}}, {{2}, {1}}]]`. See [here](http://stackoverflow.com/questions/5370848/pair-lists-to-create-tuples-in-order/5372194#5372194) for a discussion. I never fully understood this one. (Transpose will not work in the example given). – 681234 Jun 25 '11 at 08:05
3
Rotate[Grid[datasymbolgoeshere, Frame->All],90 Degree]
I like that the contents are still selectable.

Brett Champion
- 8,497
- 1
- 27
- 44
-
2...and if you like the characters to stand upright you can rotate them back too: `Rotate[Grid[Map[Rotate[#, -90 Degree] &, dalist, {-1}], Frame -> All], 90 Degree]` – Sjoerd C. de Vries Jun 25 '11 at 11:06
-
3@Sjoerd I'd use `{2}` instead of `{-1}` for the level spec, otherwise things get interesting when your data isn't atomic, such as `Array[Sin[# #2] &, {5, 5}]`. – Brett Champion Jun 25 '11 at 12:32