I have a list mapping two keys to each element, {{key1, key2}, value}, and would like to display this as a table with horizontal headers for each key1 and vertical headers for each key2, with the values being in the cells.
For example, I would like to display
{{{1, 1}, 0.54}, {{1, 2}, 0.85}, {{1, 3}, 0.24}, {{2, 1}, 0.43}, {{2, 2}, 0.99}, {{2, 3}, 0.11}, {{3, 1}, 0.10}, {{3, 2}, 0.23}, {{3, 3}, 0.94}}
as:
1 2 3
1 0.54 0.85 0.24
2 0.43 0.99 0.11
3 0.10 0.23 0.94
What is the easiest way to do this?
lst
, does this work in general?TableForm[GatherBy[lst, #[[1, 1]] &][[All, All, 2]], TableHeadings -> Transpose@lst[[All, 1]]]
$\endgroup$