After searching a lot from this forum and @Anton Anton's codes on Cross Tabulation
, i still cannot find the way to create a dataset table with two-row headers. The first row has two header Keys
: First
and Last
, and the second row header is {a, b, c, d}
as shown in the following dataset
:
dataset = Dataset[{
<|"a" -> 1, "b" -> "x", "c" -> {1}, "d" -> {1}|>,
<|"a" -> 2, "b" -> "y", "c" -> {2, 3}, "d" -> {1}|>,
<|"a" -> 3, "b" -> "z", "c" -> {3}, "d" -> {1}|>,
<|"a" -> 4, "b" -> "x", "c" -> {4, 5}, "d" -> {1}|>,
<|"a" -> 5, "b" -> "y", "c" -> {5, 6, 7}, "d" -> {1}|>,
<|"a" -> 6, "b" -> "z", "c" -> {}, "d" -> {1}|>}]
Can some show me how to create a dataset table in which the key First
should be above a
and b
together and the key Last
be above c
and d
together?
EDIT
Actually, no need for an image of the desired output. Here are the header Keys
:
(*top row header*)
head1 = {"First", "Last"} (* where its elements are defined as *)
"First" -> {"a", "b"}
"Last" -> {"c", "d"}
(*second row header under the top row*)
head2={"a", "b","c", "d"}
EDIT 1 Here is an image of the format I am after.
Code
for showing the desired output format, I will edit my question with an image of the desired format. $\endgroup$Code
I am after. I cannot put the desired output inRaw Input Form
but I edited the question with extra info. $\endgroup$dataset
given in the question to havetwo rows of Keys
. In the top row, there are two variables (First
andLast
) and in the second row, fourKeys
are distributed acrossFirst
andLast
in the way shown in EDIT. $\endgroup$Dataset[Take[ExampleData[{"Dataset", "Planets"}], All, -2], DatasetTheme -> "Detailed"]
with the Moons? $\endgroup$