Just to clarify all this as an answer
First, generate some data
y <- c(1:10)
x <- c(rep(0, 4), rep(1, 6))
dat <- data.frame(y, x)
now fit a linear model
summary(lm(y ~ x, data = dat))
Call:
lm(formula = y ~ x, data = dat)
Residuals:
Min 1Q Median 3Q Max
-2.50 -1.25 0.00 1.25 2.50
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 2.5000 0.8385 2.981 0.01756 *
x 5.0000 1.0825 4.619 0.00171 **
Residual standard error: 1.677 on 8 degrees of freedom
Multiple R-squared: 0.7273, Adjusted R-squared: 0.6932
F-statistic: 21.33 on 1 and 8 DF, p-value: 0.001713
Note that the intercept is indeed the mean of $y$ for $x==0$
Now centre $x$ and repeat
x2 <- x - mean(x)
x2
[1] -0.6 -0.6 -0.6 -0.6 0.4 0.4 0.4 0.4 0.4 0.4
summary(lm(y ~ x2, data = dat))
Call:
lm(formula = y ~ x2, data = dat)
Residuals:
Min 1Q Median 3Q Max
-2.50 -1.25 0.00 1.25 2.50
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 5.5000 0.5303 10.371 6.46e-06 ***
x2 5.0000 1.0825 4.619 0.00171 **
Residual standard error: 1.677 on 8 degrees of freedom
Multiple R-squared: 0.7273, Adjusted R-squared: 0.6932
F-statistic: 21.33 on 1 and 8 DF, p-value: 0.001713
Note that the coefficient is unchanged as the difference between the predicted means for the two categories remains unchanged but the intercept has been shifted to represent the hypothetical value predicted for $x2 == 0$.
Although centering can be an excellent idea it does not do much of interest with categorical predictors.