title: Using `subset()` within a secondary R function
body: <p>When requested, function <code>foo1</code> can <code>subset</code> a list <code>by</code> a desired variable (e.g., <code>by = ESL == 1</code>). Otherwise, <code>foo1</code> will simply output the inputted list itself.</p>
  
  <p>For my purposes, I need to use <code>foo1</code> within a new function called <code>foo2</code>. <strong>BUT</strong> I'm wondering why <code>foo2</code> fails and how to fix it:</p>
  
  <p><code>Error in eval(e, x, parent.frame()) : object 'ESL' not found</code></p>
  
  <p>The full reproducible data and code is below:</p>
  
  <pre><code>foo1 &lt;- function(by, data){
  
  L &lt;- split(data, data$study.name) ; L[[1]] &lt;- NULL
  
   if(!missing(by)){
  
   s &lt;- substitute(by)    
  
   H &lt;- lapply(L, function(x) do.call("subset", list(x, s)))
  
   L &lt;- Filter(nrow, H)
     }
  return(L)
  }
  
  ## EXAMPLE OF USE:
  D &lt;- read.csv("https://raw.githubusercontent.com/izeh/i/master/k.csv", h = T) ## Data
  
  foo1(data = D, by = ESL == 1) ## works fine :-) @@@@
  
  ## BUT:
  foo2 &lt;- function(by, data){
  
    foo1(by = by, data = data)
  }
  
  ## EXAMPLE OF USE:
  foo2(data = D, by = ESL == 1) ## Fails :-( @@@@
  </code></pre>