alloc
is a character variable, the coercion to a factor via the factor()
function isn't strictly necessary (since this would have happened automatically anyway), but it's better to be explicit. In some cases, a numeric variable may in fact be used to represent levels of a categorical variable, in which case use of the factor()
function is crucial.