title: Way to extract data from lm-object before function is applied?
body: <p>let me directly dive into an example to show my problem:</p>
  
  <pre><code> rm(list=ls())
   n &lt;- 100
   df &lt;- data.frame(y=rnorm(n), x1=rnorm(n), x2=rnorm(n) )
   fm &lt;- lm(y ~ x1 + poly(x2, 2), data=df)
  </code></pre>
  
  <p>Now, I would like to have a look at the previously used data. This is almost available by using</p>
  
  <pre><code> temp.data &lt;- fm$model
  </code></pre>
  
  <p>However, <code>x2</code>will have been split up into <code>poly(x2,2)</code>, which will itself be a dataframe as it contains a value for <code>x2</code> and <code>x2^2</code>. Note that it may seem as if <code>x2</code> is contained here, but since the polynomal uses orthogonal components, <code>temp.data$x2</code> is not the same as <code>df$x2</code>. This can also be seen if you compare the variables visually after, say, the following: <code>new.dat &lt;- cbind(df, fm$model)</code>.</p>
  
  <p>Now, to some questions:</p>
  
  <p>First, and most importantly, is there a way to retrieve <code>x2</code> from the lm-object in its original form. Or more generally, if some function <code>f</code> has been applied to some variable in the lm-formula, can the underlying variables be extracted from the lm-object (without doing case-specific math)? Note that I know I could retrieve the data by other means, but I wonder if I can extract it from the lm-object itself. </p>
  
  <p>Second, on a more general note, since I did explicitly not ask for <code>model.matrix(fm)</code>, why do I get data that has been manipulated? What is the underlying philosophy behind that? Does anyone know? </p>
  
  <p>Third, the command <code>head(new.dat)</code> shows me that <code>x2</code> has been split up in two components. What I see when I type <code>View(new.dat)</code> is, however, only one column. This strikes me as puzzling and mindboggling. How can two colums be represented as one, and why is there a difference between <code>head</code> and <code>View</code>? If anyone can explain, I would be highly indebted! </p>
  
  <p>If these questions are too basic, please apologize. In this case, I would appreciate any pointers to relevant manuals where this is explained.</p>
  
  <p>Thanks in advance!</p>