Session Ready
Exercise

Cast a column as a factor

Factors are categorical variables, where the possible values are a fixed and known set. For example, take a simple factor like bake below:

bake <- c("pie", "cake", "neither") 
parse_factor(bake, levels = NULL) 
[1] pie  cake neither
Levels: pie cake neither

You can use parse_factor() to parse variables and col_factor() to cast columns as categorical. Both functions have a levels argument that is used to specify the possible values for the factors. When levels is set to NULL, the possible values will be inferred from the unique values in the dataset. Alternatively, you can pass a list of possible values.

This is the last time you'll read in "desserts.csv"! This time, you will look at the result column, which contains the outcome of the competition for each baker.

Instructions
100 XP

Adapt your code from the previous exercise to cast result as a factor; detect the factor levels based on the unique values present in each variable. Use glimpse() to check your work.