reordercats
Reorder categories in a categorical array.
📝Syntax
B = reordercats(A)
B = reordercats(A, newOrder)
📥Input Arguments
Parameter Description
A Input categorical array.
newOrder New category order, specified by category names or numeric positions.
📤Output Arguments
Parameter Description
B Categorical array with the same displayed values as A and a reordered category list.
📄Description

reordercats changes the order of categories. If newOrder is omitted, categories are sorted by name.

For ordinal arrays, the new category order changes relational comparisons and sorting order.

💡Examples
Specify a new order.
A = categorical({'red','blue'}, {'red','blue'}); B = reordercats(A, {'blue','red'}); categories(B)
Sort categories by name.
A = categorical({'plane','car','train'}); B = reordercats(A); categories(B)
🔗See Also
categoriesrenamecatsisordinalsort
🕔Version History
Version Description
2.0.0 initial version
Edit this page on GitHub