title: Capture a data.frame (or non-atomic) object with lazyeval
body: <p>Is there a (preferred) way to capture a data.frame or other non-atomic object lazily using the <code>lazyeval</code> package?  It seems <code>lazyeval</code> prevents this:</p>
  
  <pre><code>library(lazyeval)
  data(iris)
  f &lt;- function(x) lazyeval::lazy_(x, parent.frame() )
  f(iris)
  </code></pre>
  
  <p>I get this error:</p>
  
  <pre><code>Error: is.call(expr) || is.name(expr) || is.atomic(expr) is not TRUE 
  </code></pre>
  
  <p>On atomic objects this works as expected, a lazy object is returned with an unevaluated expression and the environment. </p>
  
  <pre><code>&gt; f(1:10)
  &lt;lazy&gt;
    expr: 1:10
    env:  &lt;environment: R_GlobalEnv&gt;
  </code></pre>
  
  <h2>Expected output</h2>
  
  <p>I am pretty surprised since the docs say: </p>
  
  <blockquote>
    <p>Use lazy() like you'd use substitute() to capture an unevaluated
    promise.</p>
  </blockquote>
  
  <p>and <code>subsitute</code> can be used to capture an unevaluated <em>name</em> (getting the parent.frame is trivial):</p>
  
  <pre><code>&gt; f &lt;- function(x) substitute(x)
  &gt; f(iris)
  iris      # name
  </code></pre>
  
  <p>What I would expect from lazyeval is:</p>
  
  <pre><code>f(iris) 
  &lt;lazy&gt;
    expr: iris
    env:  &lt;environment: R_GlobalEnv&gt;
  </code></pre>
  
  <p>I am likely missing something?  Help?</p>
  
  <h2>Relevant Info</h2>
  
  <pre><code>&gt; R.version.string
  [1] "R version 3.2.1 (2015-06-18)"
  
  &gt; packageVersion('lazyeval')
  [1] 0.1.10.9000
  </code></pre>
  
  <h2>Update</h2>
  
  <p>@MrFlick has a decent pair of answers (see below), but neither produce the expected output:</p>
  
  <pre><code>&gt; f &lt;- function(x) lazyeval::lazy(x,parent.frame())
  &gt; f(iris)
  &lt;lazy&gt;
    expr: structure(list(Sepal.Length = c(5.1, 4.9, 4.7, 4.6, 5, 5.4, 4.6,  ...
    env:  &lt;environment: R_GlobalEnv&gt;
  </code></pre>
  
  <p>This stores the iris in <code>expr</code>; only the name is desired.</p>
  
  <pre><code>&gt; f &lt;- function(x) lazyeval::lazy_( quote(x), parent.frame() )
  &gt; f(iris)
  &lt;lazy&gt;
    expr: x
    env:  &lt;environment: R_GlobalEnv&gt;
  </code></pre>
  
  <p>This capture the right <code>env</code>, but the wrong expression.</p>
  
  <h2>Answer</h2>
  
  <p>Inpsired by @MrFlick, this seems to work, but it requires an additional <code>subtitute</code> to make it work correctly.  I am not entirely sure why, however:</p>
  
  <pre><code>f &lt;- function(x) lazyeval::lazy_( substitute(x), parent.frame() )
  f(iris)
  f(1:10)
  a = 1:5
  f(a)
  </code></pre>