Tools for Working with Categorical Variables (Factors)
Convert input to a factor
Anonymise factor levels
Concatenate factors, combining levels
Collapse factor levels into manually defined groups
Count entries in a factor
Combine levels from two or more factors to create a new factor
Drop unused levels
Add additional levels to a factor
Make missing values explicit
Reorder factor levels by first appearance, frequency, or numeric order
Lump uncommon factor levels together into "other"
Test for presence of levels in a factor
Convert between NA values and NA levels
Manually replace levels with "other"
Change factor levels by hand
Relabel factor levels with a function, collapsing as necessary
Reorder factor levels by hand
Reorder factor levels by sorting along another variable
Reverse order of factor levels
Shift factor levels to left or right, wrapping around at end
Randomly permute factor levels
Unify the levels in a list of factors
Unique values of a factor, as a factor
Create a factor
forcats: Tools for Working with Categorical Variables (Factors)
Find all levels in a list of factors
Low-level functions for manipulating levels
Pipe operator
Helpers for reordering factor levels (including moving specified levels to front, ordering by first appearance, reversing, and randomly shuffling), and tools for modifying factor levels (including collapsing rare levels into other, 'anonymising', and manually 'recoding').
Useful links