For these exercises we will use the US murders dataset. Make sure you load it prior to starting.

library(dslabs)
data("murders")

Using the str function, we saw that the region column stores a factor. You can confirm this by using the class function on the region column.

class(murders$region)
#> [1] "factor"

Exercise

  1. Determine the names of the different regions. Use the function levels. Store your result in an object named levels_names.

  2. Determine how many different regions are included. Use the function nlevels. Store your result in an object named levels_count.