How to | Put Headings in a Table
The Wolfram Language provides great flexibility for displaying and styling headings in a table. You can use Prepend or ArrayFlatten to add headings to rows and columns and then use Grid with any of its styling elements to display them in a table.
The Wolfram Language lets you control and customize the display of data in your table. Headings are just like any other element of a table.
Set up a table of values:
Prepend headings for columns:
Display the data, with column headings, using Grid:
Use MapThread to prepend headings for rows:
Display the data with headings for rows and columns, using Grid with Frame:
Set up a table of circles:
Use GraphicsGrid to display the circles in a grid:
Create and style column headings:
Prepend the styled column headings to the circles:
View the styled table with GraphicsGrid:
The following data represents yields for three types of soils and two types of corn seeds:
The data can be grouped by soil type by using First with GatherBy to gather the data by the first element of each data point:
To prepare the data for display in a table, use Flatten at level one, which here makes one list of triples. The % symbol specifies the most recent output, which in this case is the grouped data:
The observation number within each soil type will serve as the corresponding row heading.
Use Length to count the number of observations within each soil type:
Use Range to generate a list of successive integers beginning with 1 and ending with the number of observations within each soil type:
Prepare the numbers for use as row headings by using Flatten to compress them into a single list:
Create column headings for the soil type, seed type, and yield data. You will create a column heading for the observation number in the next step, so you do not need to do so here:
Use ArrayFlatten to add the observation numbers, along with the column heading "Observation", to the data:
Use Grid to display the data in a table:
Use some of the options available in Grid to add styling to the table:
For more examples of table formatting and styling, see "How to: Format a Table of Data", and "Grids, Rows, and Columns".
You can also create tables and add headings to them using TableForm.
Define a set of data to work with:
Create the row and column headings for your data:
Create a table with TableForm, and use the TableHeadings option to add your headings:
While TableForm allows you to create tables, it does not support the extensive styling options that are available to Grid.