# Linear Regression for One Categorical Explanatory Variable

Perform linear regression for a categorical variable in R and learn the principles behind it.

We introduced simple linear regression that involves modeling the relationship between a numerical outcome variable `continent`

. Our model won’t yield a best-fitting regression line like it did previously, but rather offsets relative to a baseline for comparison.

As we did before when studying the relationship between teaching scores and beauty scores, let’s output the regression table for this model. Recall that this is done in two steps:

We first fit the linear regression model using the

`lm(y ~ x, data)`

function and save it in`lifeExp_model`

.We get the regression table as the code output by applying the

`get_regression_table()`

function from the`moderndive`

package to`lifeExp_model`

.

Get hands-on with 1200+ tech skills courses.