Using the str
function, we saw that the League
column stores a factor. You can corroborate this by using the class
function on the League
column.
class(Hitters$League)
#> [1] "factor"
The question of this exercise is how many types of leagues are included.
For this question we will combine two functions, in a nested way, to determine the number of unique categories. Use the functions levels
and length
to determine the number of regions defined by this dataset and contained in Hitters$League
.
NOTE
Do not forget to first load the data as in the previous exercises!