Documentation

This is machine translation

Translated by Microsoft
Mouse over text to see original. Click the button below to return to the English verison of the page.

summary

Print summary of table, timetable, or categorical array

Syntax

Description

example

summary(T) prints a summary of the table or timetable, T.

  • If T is a table, then the table summary displays the description from T.Properties.Description followed by a summary of the table variables.

  • If T is a timetable, then the timetable summary displays the description from T.Properties.Description, a summary of the row times, and then a summary of the timetable variables.

example

summary(A) prints a summary of the categorical array, A.

  • If A is a vector, then summary(A) displays the category names along with the number of elements in each category (the category counts). Furthermore, the summary contains the number of elements that are undefined.

  • If A is a matrix, then summary treats the columns of A as vectors and displays the category counts for each column of A.

  • If A is a multidimensional array, then summary acts along the first array dimension whose size does not equal 1.

example

summary(A,dim) prints the category counts of the categorical array, A, along dimension dim.

For example, you can display the counts of each row in a categorical array using summary(A,2).

Examples

collapse all

Create a table.

load patients
BloodPressure = [Systolic Diastolic];
T = table(Gender,Age,Smoker,BloodPressure,'RowNames',LastName);

Add descriptions and units to table T.

T.Properties.Description = 'Simulated patient data';
T.Properties.VariableUnits =  {''  'Yrs' ''  'mm Hg'};
T.Properties.VariableDescriptions{4} = 'Systolic/Diastolic';

Print a summary of table T.

format compact

summary(T)
Description:  Simulated patient data
Variables:
    Gender: 100×1 cell array of character vectors
    Age: 100×1 double
        Units:  Yrs
        Values:
            min       25   
            median    39   
            max       50   
    Smoker: 100×1 logical
        Values:
            true     34      
            false    66      
    BloodPressure: 100×2 double
        Units:  mm Hg
        Description:  Systolic/Diastolic
        Values:
                      BloodPressure_1    BloodPressure_2
                      _______________    _______________
            min       109                  68           
            median    122                81.5           
            max       138                  99           

summary displays the minimum, median, and maximum values for each column of the variable BloodPressure.

Create a small timetable.

Time = [seconds(1:5)]';
TT = timetable(Time,[98;97.5;97.9;98.1;97.9],[120;111;119;117;116],...
               'VariableNames',{'Reading1','Reading2'})
TT = 

     Time    Reading1    Reading2
    _____    ________    ________

    1 sec      98        120     
    2 sec    97.5        111     
    3 sec    97.9        119     
    4 sec    98.1        117     
    5 sec    97.9        116     

Print a summary of the timetable. summary prints a summary of the row times, followed by a summary of the variables. If the timetable is regular, then summary also prints the size of the time step between row times.

summary(TT)
RowTimes:

    Time: 5×1 duration
        Values:

            min          1 sec 
            median       3 sec 
            max          5 sec 
            TimeStep     1 sec 

Variables:

    Reading1: 5×1 double
        Values:

            min       97.5      
            median    97.9      
            max       98.1      

    Reading2: 5×1 double
        Values:

            min       111       
            median    117       
            max       120       

Create a 1-by-5 categorical vector.

A = categorical({'plane' 'car' 'train' 'car' 'plane'})
A = 

     plane      car      train      car      plane 

A has three categories, car, plane, and train.

Print a summary of A.

summary(A)
     car      plane      train 
       2          2          1 

car appears in two elements of A, plane appears in two elements, and train appears in one element.

Since A is a row vector, summary lists the occurrences of each category horizontally.

Create a 3-by-2 categorical array, A, from a numeric array.

X = [1 3; 2 1; 3 1; 4 2];
valueset = 1:3;
catnames = {'red' 'green' 'blue'};

A = categorical(X,valueset,catnames)
A = 

     red              blue  
     green            red   
     blue             red   
     <undefined>      green 

A has three categories, red, green, and blue. The value, 4, was not included in the valueset input to the categorical function. Therefore, the corresponding element, A(4,1), does not have a corresponding category and is undefined.

Print a summary of A.

summary(A)
     red              1      2 
     green            1      1 
     blue             1      1 
     <undefined>      1      0 

red appears in one element in the first column of A and two in the second column.

green appears in one element in the first column of A and none in the second column.

blue appears in one element in the first column of A and one in the second column.

A contains only one undefined element. It occurs in the first column.

Create a 3-by-2 categorical array, A, from a numeric array.

A = categorical([1 3; 2 1; 3 1],1:3,{'red' 'green' 'blue'})
A = 

     red        blue 
     green      red  
     blue       red  

A has three categories, red, green, and blue.

Print a summary of A along the second dimension.

summary(A,2)
     red      green      blue 
       1          0         1 
       1          1         0 
       1          0         1 

red appears in one element in the first row of A, one in the second row, and one in the third row.

green appears in only one element. It occurs in the second row of A.

blue appears in one element in the first row of A and one in the third column.

Input Arguments

collapse all

Input table, specified as a table or a timetable.

Categorical array, specified as a vector, matrix, or multidimensional array.

Dimension of A to operate to along, specified as a positive integer scalar. If no value is specified, the default is the first array dimension whose size does not equal 1.

Consider a two-dimensional categorical array, A:

If dim = 1, then summary(A,1) displays the category counts for each column of A.

If dim = 2, then summary(A,2) returns the category counts of each row of A.

If dim is greater than ndims(A), then summary(A) returns an array the same size as A for each category. summary returns 1 for elements in the corresponding category and 0 otherwise.

More About

collapse all

Table Summary

The table summary displays the table description from T.Properties.Description followed by information on the variables of T.

The summary contains the following information on the variables:

  • Name: Size and Data Type — variable name from T.Properties.VariableNames, the size of the variable, and the data type of the variable.

  • Units — variable's units from T.Properties.VariableUnits.

  • Description — variable's description from T.Properties.VariableDescriptions.

  • Values — only included for numeric, logical, categorical, datetime, or duration variables.

    • numeric, datetime, or duration variables — minimum, median, and maximum values.

    • logical variables — number of values that are true and the number of values that are false.

    • categorical variables — number of elements from each category.

If T is a timetable, then the summary contains the same information on the vector of row times.

Tall Array Support

This function supports tall arrays with the limitations:

Some fields in the tall table summary can be impossible to calculate in a reasonable amount of time, such as the median.

For more information, see Tall Arrays.

Introduced in R2013b

Was this topic helpful?