This is functional version of `groupBy` operator. This operator groups the data using particular dimensions and by
reducing measures. It expects a list of dimensions using which it projects the datamodel and perform aggregations to
reduce the duplicate tuples. Refer this document to know the
intuition behind groupBy.
DataModel by default provides definition of few Reducers.
User defined reducers can also be registered.
- Source:
Example
//@preamble_start
Promise.all([loadData('/static/cars.json'), loadData('/static/cars-schema.json')]).then(function (params) {
const data = params[0];
const schema = params[1];
const DataModel = muze.DataModel;
const dm = new DataModel(data, schema);
//@preamble_end
// DataModel instance is created from https://www.charts.com/static/cars.json data,
// https://www.charts.com/static/cars-schema.json schema and assigned to variable dm. DataModel is extracted from
// muze namespace and assigned to the DataModel variable.
const groupBy = DataModel.Operators.groupBy;
const groupedFn = groupBy(['Year'], { horsepower: 'max' } );
const outputDM = groupByFn(dm);
//@preamble_start
printDM(outputDM);
});
//@preamble_end