Search code examples
rlinear-regression

extract predictor names from (generalized) linear models in R


When predictors are factors (categories), coef(glm) or summary(glm) list all dummy variables. Is there a way to list just the variable names present in the model as a character vector without splitting up a single factor into C-1 dummy variables?


Solution

  • Sorry, just figured it out myself:

    attr(glm$terms, "term.labels")