@stdlib/utils
Version:
Standard utilities.
34 lines (24 loc) • 872 B
Plain Text
{{alias}}( collection )
Generates a frequency table.
The table is an array of arrays where each sub-array corresponds to a unique
value in the input collection. Each sub-array is structured as follows:
- 0: unique value.
- 1: value count.
- 2: frequency percentage.
If provided an empty collection, the function returns an empty array.
Parameters
----------
collection: Array|TypedArray|Object
Input collection to tabulate. If provided an object, the object must be
array-like (excluding strings and functions).
Returns
-------
out: Array<Array>|Array
Frequency table.
Examples
--------
> var collection = [ 'beep', 'boop', 'foo', 'beep' ];
> var out = {{alias}}( collection )
[ [ 'beep', 2, 0.5 ], [ 'boop', 1, 0.25 ], [ 'foo', 1, 0.25 ] ]
See Also
--------