Main Content

Filter by group

filters the data in a table or timetable according to the computation in
`G`

= groupfilter(`T`

,`groupvars`

,`method`

)`method`

, grouping by the unique combinations of grouping variables
specified in `groupvars`

. The `method`

argument is a
function handle that operates on each nongrouping variable. The output
`G`

is a table or timetable containing only the rows of
`T`

that satisfy the condition in `method`

. For
example, `G = groupfilter(T,'Trial',@(x) numel(x) > 5)`

groups the data
in `T`

by `Trial`

, keeping the rows that belong to
groups with more than five trials.

bins the data according to `G`

= groupfilter(`T`

,`groupvars`

,`groupbins`

,`method`

)`groupbins`

before applying the filter,
horizontally concatenating the groups to the output table. For example, ```
G =
groupfilter(T,'SaleDate','year',@(x) numel(x) > 5)
```

bins the data in
`SaleDate`

by year, and keeps the rows whose bin has more than five
elements.

filters the data according to the unique combinations of grouping vectors in
`B`

= groupfilter(`A`

,`groupvars`

,`method`

)`groupvars`

when `A`

is a vector or matrix.
`groupvars`

can be a column vector, matrix, or cell array of column
vectors. The output `B`

is a matrix containing the rows of
`A`

that satisfy the condition defined by
`method`

.

`discretize`

| `findgroups`

| `groupcounts`

| `groupsummary`

| `grouptransform`

| `rowfun`

| `splitapply`

| `varfun`