title: lm function to return all coefficients from the model
body: <p>I'm trying to extract OLS coefficient from a set of model that run under lapply:</p>
  
  <p>The problem that not all submodel from my list have all levels and most of the time I end up with coefficients "out of bound". For example in the code below "No Reward" option is not present for Reward2 and  result0$coef[3,1] will be out of bound as there is no third estimate reported. 
  Question: is it possible to force "lm" to report all the coefficients specified in the model even if there is no estimate available?</p>
  
  <p>I would like to apologize to the community for not presenting a reproducible code on my earlier attempt. Since my last attempt I solved the problem by checking within the function for presence of a particular estimate, but the question still remains and here is the code:</p>
  
  <pre><code>RewardList&lt;-c("Reward1","Reward2")
  set.seed(1234)
  GL&lt;-rnorm(10)
  RewardName&lt;-rep(c("Reward1","Reward2"),each=5)
  NoReward&lt;-c(0,1,0,1,0,  0,0,0,0,0)
  Under1&lt;-  c(1,0,0,0,1,  0,1,0,1,0)
  Above1&lt;-  c(0,0,1,0,0,  1,0,1,0,1)
  
  tinput&lt;-as.data.frame(RewardName)
  tinput&lt;-cbind(tinput,GL,NoReward,Under1,Above1)
  
  regMF &lt;- lapply(seq_along(RewardList), 
  function (n) {
  tinput &lt;- tinput[tinput$RewardName==RewardList[n],]
  result0 &lt;- summary(lm(GL~NoReward+Under1+Above1-1,tinput))
  result1 &lt;- result0$coef[1,1] #no rebate
  result2 &lt;- result0$coef[2,1]
  result3 &lt;- result0$coef[3,1]
  return(list(result1,result2,result3))})
  </code></pre>