8.2.51 splitapply

Function: out = splitapply (func, X, G)
Function: out = splitapply (func, X1, …, XN, G)
Function: [Y1, …, YM] = splitapply (…)

Split data into groups and apply function.

func is a function handle to call on each group of inputs in turn.

X, X1, …, XN are the input variables that are split into groups for the function calls. If X is a table, then its contained variables are “popped out” and considered to be the X1XN input variables.

G is the grouping variable vector. It contains a list of integers that identify which group each element of the X input variables belongs to. NaNs in G mean that element is ignored.

Vertically concatenates the function outputs for each of the groups and returns them in as many variables as you capture.

Returns the concatenated outputs of applying func to each group.

See also: table.groupby, table.splitapply