In this part, we will learn about factors. Factors are used in R to store categorical variables. Categorical variables have a limited set of possible values, e.g., a factor named
seasons can store four possible values:
"winter". Each possible value of a factor is called a level. Factors can be very useful in some situations and not at all useful in others. Things get especially tricky if you are using those base R functions that force all character variables to be factors. However – and as you learned earlier – that's not the case in tidyverse.
We're going to use a package called forcats to work with factors. This is the tidyverse way of making factors easier to handle.