Why does 'groupsummary' error when applying function handle to an ordinal categorical table variable?
古いコメントを表示
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.
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Categorical Arrays についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!