# How to create a table?

I have looked here at the forum and on the mathematica documentation center though still couldn't get it to work.

I have two lists

data1 = Range[5,100,5];
data2 = {23.5371, 19.9289, 17.3337, 15.2521, 13.5116, 12.0224, 10.728,
9.58869, 8.57414, 7.66085, 6.83212, 6.0777, 5.39243, 4.77407,
4.22107, 3.73117, 3.30078, 2.92517, 2.59882, 2.31598};
data3 = {0.825641, 0.744071, 0.671229, 0.606114, 0.54784, 0.49552, 0.448347,
0.405579, 0.366531, 0.33061, 0.297385, 0.266627, 0.238275, 0.212363,
0.188934, 0.167979, 0.149416, 0.133096, 0.118823, 0.106381};


How can I get a table from this data form such as this:

I have tried to use Grid and tried to use TableForm but I couldn't arrange the data in a way visualized above.

Grid[Transpose@{data1, data2, data3} ~Prepend~ {"data1", "data2", "data3"},
Dividers -> {All, {1 -> True, 2 -> True, -1 -> True}}]


• A bit more compact: Dividers -> {All, {True, True, {}, True}} Sep 20, 2014 at 2:25

If you often have need of this display you will want a function to automate creating the code in Karsten's answer (with a few variations):

SetAttributes[mytable, HoldFirst]

mytable[dat : {__}?MatrixQ, opts : OptionsPattern[Grid]] :=
Grid[
Join[{Thread @ HoldForm @ dat}, dat\[Transpose]],
opts, Dividers -> {All, {1, 1, {}, 1}}
]


Example, including an additional Grid Option:

mytable[{data1, data2, data3}, Alignment -> "."]


Grid[{{"data1", "data2", "data3"}, Column /@ {data1, data2, data3}},
Frame -> All]

• The disadvantage of this is that you lose alignment between columns and other Grid niceties. Sep 19, 2014 at 22:04