Factors
Summary

Instruction

You may be wondering: what's the difference between a character vector and a factor? After all, as you saw in the previous exercise, the phone and phone_factor variables basically look the same. Why would you want to use a factor, anyway? A factor only lets you store values that belong to one of its categories, which are called levels.

You can display these levels with the levels() function, like so:

levels(houses$phone_factor)

R then returns the possible categories that phone_factor values can belong to:

[1] "N" "Y" 

Note that the categories/levels are displayed in ascending order. In this case, N is alphabetically less than Y, so it's displayed first.

Exercise

Display levels of the phone_factor variable.