I execute the following commands in MATLAB:
>> load hospital>> patients = dataset2table(hospital);>> patients.AgeBand = discretize(patients.Age, 0:10:100, 'categorical');>> assert(isordinal(patients.AgeBand))
The last line should be enough to guarantee that 'patients.AgeBand' is an ordinal categorical.
However, while I am able to apply a method through a function handle to the table variable 'Age', which is a column of doubles:
>> groupsummary(patients, "Sex", @max, "Age")
trying to do so on the column 'AgeBand', which is guaranteed to be an ordinal categorical column, results in an error which wrongly claims that 'AgeBand' is categorical and NOT ordinal:
>> groupsummary(patients, "Sex", @max, "AgeBand")Error using groupsummary (line 335)Unable to apply method 'fun1' to data variable AgeBand.Caused by: Error using categorical/max (line 77) Relational comparisons are not allowed for categorical arrays that are not ordinal.
Best Answer