title: Are gls and dynlm calls technically different (not speaking of the stats sense)?
body: <p>I wrote a small function to run multiple univariate regressions with different lags:</p>
  
  <pre><code>f &lt;- function(x,l) {
  lm.obj &lt;- dynlm(GNP~L(get(as.character(x)),l),
                data=longley)
  names(lm.obj$coefficients)[2] &lt;- paste(x,l,sep=".")
  return(lm.obj)
  }
  </code></pre>
  
  <p>this works quite well with <code>mlply</code> after creating a frame of possible lag - variable combinations using <code>expand.grid</code>. A reproducible example using the <code>longley</code> dataset from the <code>datasets</code> package looks like this:</p>
  
  <pre><code>data(longley)
  require(plyr)
  vars &lt;- expand.grid(x=names(longley)[-c(1:3)],l=1:3)
  
  regressionList &lt;- mlply(vars,f, .progress= "text")
  summaries &lt;- lapply(regressionList,summary)
  </code></pre>
  
  <p>This works quite well. However now I try to do the same thing using gls.</p>
  
  <pre><code>require(nlme)
  
  f.gls &lt;- function(x,l) {
  gls.obj &lt;- gls(GNP~lag(get(as.character(x)),-l),
                data=longley)
  names(gls.obj$coefficients)[2] &lt;- paste(x,l,sep=".")
  return(gls.obj)
  }
  </code></pre>
  
  <p>But all I get is this error:</p>
  
  <p><code>Error in eval(expr, envir, enclos) : object 'x' not found</code></p>
  
  <p>I tried to use <code>debug()</code> but everything on the inside seems the same. I als tried to call the function outside <code>mlply</code> but it did not work. Also tried with out lags. It's just that x can"t be found. </p>