title: Arguments of a function where another function will be called
body: <p>Consider a hypothetical example:</p>
  
  <pre><code>sim &lt;- function(n,p){
    x &lt;- rbinom(n,1,p)
    y &lt;- (x==0) * rnorm(n)
    z &lt;- (x==1) * rnorm(n,5,2)
  
    dat &lt;- data.frame(x, y, z)
    return(dat)
  }
  </code></pre>
  
  <p>Now I want to write another function <code>simfun</code> where I will call the above <code>sim</code> function and check if <code>y</code> and <code>z</code> columns of the data frame is less than a value <code>k</code>. </p>
  
  <pre><code>simfun &lt;- function(n, p, k){
     dat &lt;- sim(n, p)
     dat$threshold &lt;- (dat$y&lt;=k &amp; dat$z&lt;=k)
  
    return(dat$threshold)
  }
  </code></pre>
  
  <p>But is it standard to use the argument of <code>sim</code> as the argument of <code>simfun</code>? Can I write <code>simfun &lt;- function(k)</code> and call the <code>sim</code> function inside <code>simfun</code>?</p>