Pivot Table
Description
The Pivot Table task lets you interactively summarize tabular data in a pivoted table according to column and row groups. The task automatically generates MATLAB® code for your live script. For more information about Live Editor tasks generally, see Add Interactive Tasks to a Live Script.
A pivoted table provides a summary of tabular data. Pivoted tables are useful for analyzing and providing insights into large data sets and organizing data from another perspective, according to column and row groups. The column and row labels of a pivoted table are group names, and the data values are group counts or the result of another computation method. For more information, see Pivoting Operation or watch How to Create Pivot Tables in MATLAB (4 min, 11 sec).
Using this task, you can:
Create a pivoted table and specify grouping variables to designate pivoted table rows and columns.
Focus on a subset of rows by filtering the input table.
View sparklines and summary statistics to quickly visualize and interpret the data in each table or timetable variable.
Fill the values of the pivoted table by specifying the computation method and table variable.
Customize the format and contents of the pivoted table.
Visualize the pivoted table in a chart.
For more information on Live Editor tasks, see Add Interactive Tasks to a Live Script.
Related Functions
Pivot Table generates code that uses the pivot
function.
Open the Task
To add the Pivot Table task to a live script in the MATLAB Editor:
On the Live Editor tab, select Task > Pivot Table.
In a code block in the script, type a relevant keyword, such as
pivot,group,crosstab, orheatmap. SelectPivot Tablefrom the suggested command completions. For some keywords, the task automatically updates one or more corresponding parameters.
Examples
Related Examples
Parameters
Tips
The Pivot Table task can apply the computation method to at most one data variable. To apply multiple computation methods or specify multiple data variables, use the Compute by Group task.


![Figure contains an axes object. The axes object with title Values in T grouped by Smoker and Age summarized using Count contains 5 objects of type bar. These objects represent [25, 30), [30, 35), [35, 40), [40, 45), [45, 50].](../../examples/matlab/win64/BinGroupingVariableExample_03.png)


