You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: aggregate.m
    path of file: ./repos/matStats/matStats/@Table
    
    the code of the file until where you have to start completion: function res = aggregate(obj, name, op, varargin)
% Group table rows according to unique values in a vector or column.
%
%   TAB2 = aggregate(TAB, VALUES, OP)
%   VALUES is a column vector with as many elements as the number of rows
%   in the table, and OP is a mathematical operation which computes a value
%   from an array, like 'min', 'max', 'mean'...
%
%   For each unique value in VALUES, the function selects row indices such
%   that values(i)==value, and applies the operation OP to each column of
%   the selected rows. This results is a new row for each unique value in
%   VALUES.
%
%   The resulting table has as many columns as the original table, and a
%   number of rows equal to the number of unique values in VALUES. Rows are
%   labeled with the unique values in VALUES.
%   
%   TAB2 = aggregate(TAB, COLNAME, OP)
%   TAB2 = aggregate(TAB, COLINDEX, OP)
%   Uses one of the columns in the table as a basis for VALUES. In obj
%   case, the resulting table has one column left as the original table,
%   and rows are labeled using a composition of COLNAME and the unique
%   values in the column.
%
%
%   TAB2 = aggregate(..., 'rowNames', ROWNAMES)
%   Specifies the names of the rows in the new table.
%
%   Example
%     % Display mean values of each feature, grouped by Species
%     iris = Table.read('fisherIris');
%     aggregate(iris(:,1:4), iris('Species'), @mean)
%     ans = 
%                            SepalLength    SepalWidth    PetalLength    PetalWidth
%     Setosa-mean                  5.006         3.428          1.462         0.246
%     Versicolor-mean              5.936          2.77           4.26         1.326
%     Virginica-mean               6.588         2.974          5.552         2.026
%
%     % The same, but choose different row names
%     newNames = {'mean_of_Setosa', 'mean_of_Versicolor', 'mean_of_Virginica'};
%     aggregate(iris(:,1:4), iris('Species'), @mean, 'rowNames', newNames)
%     ans = 
%                               SepalLength    SepalWidth    PetalLength    PetalWidth
%     mean_of_Setosa                  5.006         3.428          1.462         0.246
%     mean_of_Versicolor              5.936          2.77           4.26         1.326
%     mean_of_Virginica               6.588         2.974          5.552         2.026
%
%
%   See also
%   groupStats
%

% ------

    
function res = aggregate(obj, name, op, varargin)
% Group table rows according to unique values in a vector or column.
%
%   TAB2 = aggregate(TAB, VALUES, OP)
%   VALUES is a column vector with as many elements as the number of rows
%   in the table, and OP is a mathematical operation which computes a value
%   from an array, like 'min', 'max', 'mean'...
%
%   For each unique value in VALUES, the function selects row indices such
%   that values(i)==value, and applies the operation OP to each column of
%   the selected rows. This results is a new row for each unique value in
%   VALUES.
%
%   The resulting table has as many columns as the original table, and a
%   number of rows equal to the number of unique values in VALUES. Rows are
%   labeled with the unique values in VALUES.
%   
%   TAB2 = aggregate(TAB, COLNAME, OP)
%   TAB2 = aggregate(TAB, COLINDEX, OP)
%   Uses one of the columns in the table as a basis for VALUES. In obj
%   case, the resulting table has one column left as the original table,
%   and rows are labeled using a composition of COLNAME and the unique
%   values in the column.
%
%
%   TAB2 = aggregate(..., 'rowNames', ROWNAMES)
%   Specifies the names of the rows in the new table.
%
%   Example
%     % Display mean values of each feature, grouped by Species
%     iris = Table.read('fisherIris');
%     aggregate(iris(:,1:4), iris('Species'), @mean)
%     ans = 
%                            SepalLength    SepalWidth    PetalLength    PetalWidth
%     Setosa-mean                  5.006         3.428          1.462         0.246
%     Versicolor-mean              5.936          2.77           4.26         1.326
%     Virginica-mean               6.588         2.974          5.552         2.026
%
%     % The same, but choose different row names
%     newNames = {'mean_of_Setosa', 'mean_of_Versicolor', 'mean_of_Virginica'};
%     aggregate(iris(:,1:4), iris('Species'), @mean, 'rowNames', newNames)
%     ans = 
%                               SepalLength    SepalWidth    PetalLength    PetalWidth
%     mean_of_Setosa                  5.006         3.428          1.462         0.246
%     mean_of_Versicolor              5.936          2.77           4.26         1.326
%     mean_of_Virginica               6.588         2.974          5.552         2.026
%
%
%   See also
%   groupStats
%

% ------
% Author: David Legland
% e-mail: david.legland@inra.fr
% Created: 2008-02-11,    using Matlab 7.4.0.287 (R2007a)
% Copyright 2008 INRA - BIA PV Nantes - MIAJ Jouy-en-Josas.


%% Process input arguments

% if operation is not specified, use 'mean' by default
if nargin < 3 || ~isa(op, 'function_handle')
    if nargin > 2
        varargin = [{op} varargin];
    end