Use a baseline including all observations in lm() When using factors in a linear model,  I would like to retrieve the 'average' effect as baseline (intercept), rather than level 1 of all factors. Is this possible?
tab <- data.frame(gl(2,5),rnorm(10)+as.numeric(gl(2,5)))
colnames(tab) <- c('pred','dat')
mylm <- lm(dat~pred,data=tab)
coefficients(mylm)

returns something like
(Intercept)       pred2 
  0.5879712   1.8542153 

coefficients are on average 1 for both intercept and pred2.
I would like to rather have intercept = 1.5, pred1 = -0.5 and pred2 = +0.5
model.matrix(mylm)

returns
         (Intercept) pred2
    1            1     0
    2            1     0
    3            1     0
    4            1     0
    5            1     0
    6            1     1
    7            1     1
    8            1     1
    9            1     1
    10           1     1
    attr(,"assign")
    [1] 0 1
    attr(,"contrasts")
    attr(,"contrasts")$pred
    [1] "contr.treatment"

I would like a matrix like this
          (Intercept)  pred1   pred2
    1            1    1     0
    2            1    1     0
    3            1    1     0
    4            1    1     0
    5            1    1     0
    6            1    0     1
    7            1    0     1
    8            1    0     1
    9            1    0     1
    10           1    0     1

Does that make sense? if not, why?
Is there some command to generate such a design matrix?
I've been looking for a way to do this without success...
 A: It does not make sense to have such a design matrix because the columns are linearly dependent  (specifically, column 1 = column 2 + column 3) so you cannot compute the OLS estimator, which requires inversion of $X'X$, where $X$ is said design matrix. Your proposed design matrix falls under what is sometimes called the "dummy variable trap". What you can do, if you want to include both 'pred1' and 'pred2', is to drop the intercept instead, but you cannot have exhaustive dummies and an intercept.
Addition
To do this in R, and with your example code, run the following: 
lm(dat ~ -1 + pred, data=tab)

The '-1' removes the intercept and then you interpret the coefficients as the mean in the respective group, that is, there is no baseline group.
A: Your coding does not make sense.
It sound like you want deviation coding (or contrast) coding rather than traditional dummy coding. The UCLA website has code to create this: http://www.ats.ucla.edu/stat/r/library/contrast_coding.htm
Or assuming you have a four level variable (unlike your example):
#the contrast matrix for categorical variable with four levels
    > contr.sum(4)
      [,1] [,2] [,3] 
    1    1    0    0
    2    0    1    0
    3    0    0    1
    4   -1   -1   -1

    #assigning the deviation contrasts to pred.f
    contrasts(tab$pred.f) = contr.sum(4)
    #the regression
    model1=lm(dat ~ pred.f, tab)
 summary(model1)

The annoying thing about R is that it will only show you the coefficients for pred2. To get all the coefficients you then have to either use the fact that the coefficients for deviation coding will add up to zero or try. 
dummy.coef(model1)

