A source of confusion that I often come across relates to when people want to use categorical data, where the number of categories is greater than 2, in a linear regression (simple or multiple) and think that they must manually code dummy variables in R representing the categories while following the rule of n - 1 to avoid the dummy variable trap.
However, doesn't R by default do the dummy encoding under the hood when using a categorical variable with the lm()
function? And isn't this the case whether the variable is a factor or a character string? The reference category should really be defined but R uses 0 if the factor variable has numeric levels and alphabetic ordering (A or closest to A) if the factor variable has character string levels. If the variable is simply a character string vector type, then R uses the same alphabetically defined reference by default.