It is because of your variable names with empty spaces, you have to quote it with backticks.
library(dplyr)
n_cars <- cars
n_cars <- n_cars %>%
mutate('n speed' = speed)
lm(dist ~ speed, data = n_cars)
> Call:
> lm(formula = dist ~ speed, data = n_cars)
> Coefficients:
> (Intercept) speed
> -17.579 3.932
lm(dist ~ n speed, data = n_cars)
> Error: unexpected symbol in "lm(dist ~ n speed"
lm(dist ~ `n speed`, data = n_cars)
> Call:
> lm(formula = dist ~ `n speed`, data = n_cars)
> Coefficients:
> (Intercept) `n speed`
> -17.579 3.932