title: How to run effect plot inside of a R function
body: <p><strong>Update:</strong> Previous title was <code>Is there any specific way to pass data frame as an argument to a function?</code> but it was not right question according to brilliant guys here. Original post is below.</p>
  
  <p>When I ran following function with <code>somefunc(sleepstudy)</code>,</p>
  
  <pre><code>somefunc&lt;-function (dataLme) 
  {
   library(effects)
   library(lme4)
  
   fm8 &lt;- lmer(Reaction ~ 1 + Days + (1 + Days|Subject), dataLme,
        REML = 0, verbose = TRUE)
  
   plot(effect("Days",fm8))
  }
  </code></pre>
  
  <p>I got an error.</p>
  
  <pre><code>Error in plot(effect("Days", fm8)) : 
    error in evaluating the argument 'x' in selecting a method for function 'plot': Error in is.data.frame(data) : object 'dataLme' not found
  </code></pre>
  
  <p>But if I manually executed</p>
  
  <pre><code>library(effects)
  library(lme4)
  fm8 &lt;- lmer(Reaction ~ 1 + Days + (1 + Days|Subject), sleepstudy,
      REML = 0, verbose = TRUE)
  plot(effect("Days",fm8))
  </code></pre>
  
  <p>I didn't get any error.</p>
  
  <p>I thought R passes by value meaning copying whole object content to the function argument. But it looks like I was not entirely right. Can anyone explain what is going on?</p>