title: An argument working outside a function but fails inside a function in R
body: <p>When outside a function, argument <code>pbkrtest.limit = nobs(m1)</code> below works just fine (thus, no message is generated).</p>
  
  <p>But when inside the <code>foo()</code> function, <code>nobs(m1)</code> is not recognized (thus, a message is generated)! I'm really wondering what is going on?</p>
  
  <pre><code>library(lme4)
  library(emmeans)
  dat &lt;- read.csv('https://raw.githubusercontent.com/hkil/m/master/z.csv')
  
  m1 &lt;- lmer(y~ year*group + (1|stid), data = dat)
  
  ## WORKS FINE:
  emtrends(m1, pairwise ~ group, var = "year", infer = c(T, T), pbkrtest.limit = nobs(m1)) 
  
  
  ## BUT NOW `nobs(m)` doesn't work inside the function:
  foo &lt;- function(m){
  
   emtrends(m, pairwise ~ group, var = "year", infer = c(T, T), pbkrtest.limit = nobs(m))
  }
  
  ## RUN:
  foo(m = m1)
  </code></pre>