(Updated 7-27-2023)

List all possible values of the variable:

table(test2$TestForm)

Linear regression

lm([target] ~ [predictor / features], data = [data source])
lmHeight2 = lm(height~age + no_siblings, data = ageandheight)

Clustered standard errors

library(estimatr)
m3 <- lm_robust(ln_wage ~ age + tenure + union + tenure:union + idcode,
                clusters = idcode,
                data = nlswork)
summary(m3)

# It can take fixed effects into account as well
m3fe <- lm_robust(ln_wage ~ age + tenure + union + tenure:union,
                  clusters = idcode,
                  fixed_effects = ~idcode,
                  data = nlswork)
summary(m3fe)