groupcounts
Count groups.
📝Syntax
counts = groupcounts(A)
[counts, groups] = groupcounts(A)
G = groupcounts(T, groupVars)
📥Input Arguments
Parameter Description
A Input array.
T Input table.
groupVars Grouping variables.
📤Output Arguments
Parameter Description
counts Number of elements in each group.
groups Unique group values.
G Table containing groups, counts, and percentages.
📄Description

groupcounts counts the number of elements or table rows in each group.

💡Examples
[counts, groups] = groupcounts([1; 1; 2; 3; 3; 3])
T = table({'a'; 'a'; 'b'}, [1; 2; 4], 'VariableNames', {'G', 'X'});
C = groupcounts(T, 'G')
🔗See Also
groupsummary
🕔Version History
Version Description
2.0.0 initial version
Edit this page on GitHub