tabulateFS

Creates frequency table of unique values of x, excluding possible 0 counts

Syntax

Description

tbl = tabulateFS(x) takes a vector x and returns a matrix, tbl. The first column of table contains the unique values of x. The second is the number of instances of each value. The last column contains the percentage of each value. This function differs from MATLAB function tabulate because it excludes 0 counts.

Remark: tabulateFS with no output arguments returns a formatted table in the command window.

example

tbl =tabulateFS(x) Tabulate Fisher iris data.

Examples

expand all

  • Tabulate Fisher iris data.
  • load fisheriris;
    tbl=tabulateFS(species);
    disp(tbl)

    Related Examples

    expand all

  • Explore the difference between tabulate and tabulateFS.
  • Run this code to see the output shown in the help file.

    % Reinitialize the random number generator to its startup
    % configuration.
    rng('default') 
    rng(100)
    x=randi([1 10],100,1);
    x(100)=30;
    % Output of tabulate
    disp('Output of MATLAB function tabulate')
    disp(tabulate(x));
    % Output of tabulateFS
    disp('Output of FSDA function tabulateFS')
    disp(tabulateFS(x));
    Output of MATLAB function tabulate
         1     9     9
         2    11    11
         3    15    15
         4    14    14
         5     4     4
         6    13    13
         7     8     8
         8     5     5
         9    11    11
        10     9     9
        11     0     0
        12     0     0
        13     0     0
        14     0     0
        15     0     0
        16     0     0
        17     0     0
        18     0     0
        19     0     0
        20     0     0
        21     0     0
        22     0     0
        23     0     0
        24     0     0
        25     0     0
        26     0     0
        27     0     0
        28     0     0
        29     0     0
        30     1     1
    
    Output of FSDA function tabulateFS
         1     9     9
         2    11    11
         3    15    15
         4    14    14
         5     4     4
         6    13    13
         7     8     8
         8     5     5
         9    11    11
        10     9     9
        30     1     1
    
    

    Input Arguments

    expand all

    x — vector for which frequency table has to be calculated. vector of numeric data or categorical variable, character array, or cell array of strings of length n.

    Data Types: double | single| categorical variable | character array, | cell array of strings

    Output Arguments

    expand all

    tbl —frequency table of data in vector x. Matrix of size unique(x)-by-3

    Information in tbl is arranged as follows:

    1st column -- The unique values of x;

    2nd column -- The number of instances of each value;

    3rd column -- The percentage of each value.

    If x is a categorical variable, character array, or cell array of strings, tbl is a cell array.

    Remark: tabulateFS with no output arguments returns a formatted table in the command window.

    References

    See Also

    This page has been automatically generated by our routine publishFS