timetable

Methods

Method Reference: timetable.groupcounts

timetable: G = groupcounts (tt, groupvars)
timetable: G = groupcounts (tt, groupvars, groupbins)
timetable: G = groupcounts (…, Name, Value)

Count the rows of a timetable in each group.

G = groupcounts (tt, groupvars) groups the rows of tt by the variables named in groupvars and returns a table with one row per group, carrying the grouping variables, a GroupCount variable and a Percent variable. The result is a table and not a timetable: its rows describe groups rather than instants, so there is nothing left for row times to label.

groupvars names one or more variables, or the row dimension name, which groups by the row times themselves.

G = groupcounts (tt, groupvars, groupbins) bins the grouping variables before grouping, groupbins being a bin count, a vector of edges, or a time unit for a datetime or duration variable.

A duration is binned by the units that have a fixed length of their own, 'second', 'minute', 'hour', 'day' and 'year'; a week, a month and a quarter have none and are refused. A narrow bin over a wide span asks for more bins than a categorical can name, and the call is refused rather than answered; MATLAB stops at 65536 bins there and returns a grid that does not reach the end of the span.

The following Name/Value pairs are accepted:

'IncludeMissingGroups'
A logical scalar. When true (the default) rows whose grouping value is missing form a group of their own, sorted last.
'IncludeEmptyGroups'
A logical scalar. When true the unused categories of a categorical or binned grouping variable are reported as groups with a count of zero. It defaults to false.
'IncludedEdge'
Which edge of a bin is included, 'left' (the default) or 'right'. It applies only where groupbins was given.

Source Code: timetable