addcats
Add categories to a categorical array.
📝Syntax
B = addcats(A, names)
B = addcats(A, names, 'Before', anchor)
B = addcats(A, names, 'After', anchor)
📥Input Arguments
Parameter Description
A Input categorical array.
names Category name or names to add. Names already present in A are ignored.
anchor Existing category used as insertion point when Before or After is specified.
📤Output Arguments
Parameter Description
B Categorical array with the same values as A and an updated category list.
📄Description

addcats appends categories to a categorical array without changing the stored elements.

For ordinal categorical arrays, the insertion position must be explicit because category order defines comparisons.

💡Examples
Add a category at the end of the list.
A = categorical({'red','blue'}); B = addcats(A, 'green'); categories(B)
Insert a category before an existing category.
A = categorical({'low','high'}, {'low','high'}, 'Ordinal', true); B = addcats(A, 'mid', 'Before', 'high'); categories(B)
🔗See Also
categoricalcategoriesremovecatsmergecatsreordercats
🕔Version History
Version Description
2.0.0 initial version
Edit this page on GitHub