renamecats
Renames categories of a categorical array.
Category: Language Fundamentals > Data Types
Syntax
B = renamecats(A, newnames)
Renames all categories in their current order.
B = renamecats(A, old, new)
Renames the category old to new.
Description
Renaming changes the label, not the values. Every element of the old category shows the new name. If the new name matches another category, the two are merged.
Input arguments
A- Categorical array.
newnames- Text or string array with one name per category.
old, new- Current name and the new name.
Output arguments
B- Categorical array with the new names; the data keep pointing to the same categories.
Example
c = categorical(["lo","hi","lo"]);
renamecats(c, "lo", "low")
Output
ans = 1×3 categorical array
low hi low