The levels() function gives you access to a variable's levels attribute. The first form sets the attribute, whereas the second returns the value of the levels of its argument.