title: model.frame and update
body: <p>In R, you might have estimated a model with a log-transformed dependent variable:</p>
  
  <pre><code>mfit &lt;- lm(
      formula = log(salary) ~ yrs.service + yrs.since.phd, 
      data    = Salaries
    )
  </code></pre>
  
  <p>Then you might want to alter the model frame and call an update to refit the model:</p>
  
  <pre><code>n     &lt;- nrow(Salaries)
  mfr   &lt;- model.frame(mfit)[sample(1:n, size=n, replace=TRUE),]
  mfit2 &lt;- update(mfit, data = mfr)
  </code></pre>
  
  <p>This will cause an error: </p>
  
  <pre><code>Error in eval(expr, envir, enclos) : object 'salary' not found
  </code></pre>
  
  <p>The reason is that the formula still has dependent variable <code>log(salary)</code> and the variable in the model frame is called <code>log(salary)</code>. R thinks that it can find <code>salary</code> and then call <code>log</code> on it. The same error would occur without the resampling, the example just shows why one might want to do it.</p>
  
  <p>The procedure above is from a bootstrap package where resampling rows is performed. Is this behavior to be expected, or is it a bug? I know that one can get around it by transforming the variables in the data argument, but this seems annoying and overlooked...</p>