Megan C. answered 10/31/19
Biostatistician, M.S.
To do this, you can relevel your factor variable. R will take the first level of the factor as the reference group (in your case, 0).
You can reassign b outside of the equation, i.e.:
b_fac <- factor(b, levels = c(3, 0, 1, 2, 4))
and then use the new factor variable in the model:
lm(x ~ y + b)
Or, you can assign the levels within the equation:
lm(x ~ y + factor(b, levels = c(3, 0, 1, 2, 4)))