title: make a list of lm objects, retain their class
body: <p>Apologies for such a rudimentary question--I must be missing something obvious.</p>
  
  <p>I want to build a list of <code>lm</code> objects, which I'm then going to use in an <code>llply</code> call to perform mediation analysis on this list. But this is immaterial--I just first want to make a list of length m (where m is the set of models) and each element within m will itself contain n <code>lm</code> objects. </p>
  
  <p>So in this simple example</p>
  
  <pre><code>d1 &lt;- data.frame(x1 = runif(100, 0, 1),
               x2 = runif(100, 0, 1),
               x3 = runif(100, 0, 1),
               y1 = runif(100, 0, 1),
               y2 = runif(100, 0, 1),
               y3 = runif(100, 0, 1))
  
  m1 &lt;- lm(y1 ~ x1 + x2 + x3, data = d1)
  m2 &lt;- lm(x1 ~ x2 + x3, data = d1)
  m3 &lt;- lm(y2 ~ x1 + x2 + x3, data = d1)
  m4 &lt;- lm(x2 ~ x1 + x3, data = d1)
  m5 &lt;- lm(y3 ~ y1 + y2 + x3, data = d1)
  m6 &lt;- lm(x3 ~ x1 + x2, data = d1)
  </code></pre>
  
  <p>I want a list containing 3 elements, and the first element will contain <code>m1</code> and <code>m2</code>, the second will contain <code>m3</code> and <code>m4</code>, etc. My initial attempt is sort of right, but the lmm objects don't retain their class.</p>
  
  <pre><code>mlist &lt;- list(c(m1,m2),
                c(m3,m4),
                c(m5,m6))
  </code></pre>
  
  <p>It has the right length (ie <code>length(mlist)</code> equals 3), but I thought I could access the <code>lm</code> object itself with</p>
  
  <pre><code>class(mlist[1][[1]])
  </code></pre>
  
  <p>but this element is apparently a list.</p>
  
  <p>Am I screwing up how I build the list in the first step, or is this something more fundamental regarding lm objects?</p>