© Thomas Mailund 2019
Thomas MailundR Data Science Quick Referencehttps://doi.org/10.1007/978-1-4842-4894-2_9

9. Working with Factors: forcats

Thomas Mailund1 
(1)
Aarhus, Denmark
 

If you work with categorical data, you can often represent the categories by strings. Strings have some drawbacks, however. For example, a spelling mistake can easily go undiscovered. If you want your categories ordered, then the lexicographical order on strings will not always be the order you need. As an alternative to strings for categories is factors. In this chapter, we look at the functionality that the forcats package provides for creating and manipulating factors.

The package is loaded when you import tidyverse,
library(tidyverse)
but you can also load it explicitly ...

Get R Data Science Quick Reference: A Pocket Guide to APIs, Libraries, and Packages now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.