title: Extract a data frame using model.frame and formula
body: <p>I want to extract a data frame using a formula, which specifies which columns to select and <strong>some crossing overs among columns</strong>. </p>
  
  <p>I know <code>model.frame</code> function. However it does not give me the crossing overs:</p>
  
  <p>For example:</p>
  
  <pre><code>df &lt;- data.frame(x = c(1,2,3,4), y = c(2,3,4,7), z = c(5,6, 9, 1))
  f &lt;- formula('z~x*y')
  model.frame(f, df)
  </code></pre>
  
  <p>output:</p>
  
  <pre><code>&gt; df
    x y z
  1 1 2 5
  2 2 3 6
  3 3 4 9
  4 4 7 1
  &gt; f &lt;- formula('z~x*y')
  &gt; model.frame(f, df)
    z x y
  1 5 1 2
  2 6 2 3
  3 9 3 4
  4 1 4 7
  </code></pre>
  
  <p>I hope to get:</p>
  
  <pre><code>  z x y x*y
  1 5 1 2 2
  2 6 2 3 6
  3 9 3 4 12
  4 1 4 7 28
  </code></pre>
  
  <p>Is there a package that could achieve this functionality? (It would be perfect if I can get the resulting matrix as a <strong>sparse matrix</strong> because the crossed columns will be highly sparse)</p>