title: converting mixed dataframe with list to pure dataframe
body: <p>what is the easiest way to extract information from a list embedded within a dataframe? </p>
  
  <pre><code>    a&lt;-data.frame(cyl=c(4,6,8),k=c("A","B","C"))
      j&lt;-by(data=mtcars,INDICES=mtcars$cyl,function(x) lm(mpg~disp,data=x))
      a$l&lt;-j
  
      t(sapply(a$l,coef))-&gt;a$t
  </code></pre>
  
  <p>But this results in a matrix embedded within the dataframe and it needs some massaging in order to have it as two columns in a with their associated column names.</p>
  
  <p>What I'd like is an easier method to extract this information and have it stored in dataframe <code>a</code> with the associated column names.</p>
  
  <p>EDIT_ This is what I had in mind, but I just found the procedure somewhat cumbersome.</p>
  
  <pre><code>t(sapply(a$l,coef))-&gt;a$t
  as.data.frame(a$t)-&gt;g
  g$cyl&lt;-as.numeric(rownames(g))
  merge(x = a,y = g)-&gt;a2
  a2[,-c(3,4)]-&gt;a3
  </code></pre>
  
  <p>Any simpler ways of doing this? </p>
  
  <p>Now, to complicate matters- What If I´d like to get the residuals from <code>a$l</code> by cylinder.</p>
  
  <pre><code>sapply(a$l,function(x) x[['residuals']])-&gt;a$t
  </code></pre>
  
  <p>How can I generate a new dataframe in a long format with two columns: cyl and residual that later can be merged with the original dataframe a?</p>