Change order of levelsKeep the values of the levels the same, but change their order. These are particularly useful for models, tables, and visualisations. |
|
---|---|
Reorder factor levels by hand |
|
Reorder factor levels by first appearance, frequency, or numeric order |
|
Reorder factor levels by sorting along another variable |
|
Randomly permute factor levels |
|
Reverse order of factor levels |
|
Shift factor levels to left or right, wrapping around at end |
|
Change value of levelsChange factor levels, while preserving order (as much as possible). |
|
Anonymise factor levels |
|
Collapse factor levels into manually defined groups |
|
|
Lump together factor levels into "other" |
Replace levels with "other" |
|
Change factor levels by hand |
|
Automatically relabel factor levels, collapse as necessary |
|
Add/remove levelsLeave existing data as is, but add or remove levels. |
|
Add additional levels to a factor |
|
Make missing values explicit |
|
Drop unused levels |
|
Unify the levels in a list of factors |
|
Combine multiple factors |
|
Concatenate factors, combining levels |
|
Combine levels from two or more factors to create a new factor |
|
Other helpers |
|
Convert input to a factor |
|
Count entries in a factor |
|
Test for presence of levels in a factor |
|
Unique values of a factor |
|
Low-level functions for manipulating levels |
|
Find all levels in a list of factors |
|
Data |
|
A sample of categorical variables from the General Social survey |