I agree with @Peter_Griffin that it's best to avoid spaces in your variable names to begin with! If for some reason you really need to use a variable with a space in lm, however, you can enclose the variable name in backticks:
mtcars_badnames <- mtcars
names(mtcars_badnames)[3] <- "Engine Displacement"
lm(`Engine Displacement` ~ factor(cyl), data = mtcars_badnames)
#>
#> Call:
#> lm(formula = `Engine Displacement` ~ factor(cyl), data = mtcars_badnames)
#>
#> Coefficients:
#> (Intercept) factor(cyl)6 factor(cyl)8
#> 105.14 78.18 247.96
Created on 2018-05-29 by the reprex package (v0.2.0).