A function to perform a group by operation. This function groups data according to the unique values in the target column of the data, splits the data according to those groups and applies a function to the split data.
[outputs] = group_by(header, data, sheader, sdata, target_column, fun_name)
m x 1 vector of headers for numeric data
n x m matrix of numeric data, with matrix of column vectors
p x 1 matrix of corresponding headers for string/text data
n x p matrix of string/text data with data as column vectors
Column on which to group the data and calculate the relevant statistics
function by which to aggregate the data, the options are "mean", "sum", "min", "max", "stdev" and "count"
structure containing grouped data for each matrix column, and the corresponding headers and unique groups.
If the data is provided in an n x m matrix, and the group volumn has p unique groups. The output of this function contains the result of applying the desired function to the split groups. A structure with the following fields is returned:
data: The result of applying the function to the grouped data, a p x m matrix
header: The header data for the data, a 1 x m matrix
rows: The unique groups which the data was split into and aggregated, a 1 x p matrix
group: a structure with fields of the unique groups, each containing a row vector of data corresponding to the header data