title: Extracting slopes from several regression models using dplyr
body: <p>I would like to fit multiple models for each individual and each drug (both are the factor variable) using dplyr, I'm getting an error, and I'm not quite sure what's wrong. I want to extract the slope of each model to compute the average slope of the pairwise relationship of fitted model between individuals.</p>
  
  <pre><code>df.dr &lt;- data.frame(
  drug = factor(rep(rep(LETTERS[1:4], each = 5), 4)), 
  individual = factor(rep(letters[1:4], each = 20)),
  dose = rep(c(10,5,1,0.5,0.1), times = 16),
  viability = runif(80, min = 50, max = 200))
  
  dfDrugInd = df.dr %&gt;% group_by(drug, individual) %&gt;%
    do(fitAll = lm(viability ~ ., data = .))
  
  dfDrugIndSlope = tidy(dfDrugInd, fitAll)$estimate[2,1]
  
  mean(dfDrugIndSlope)
  </code></pre>