title: About the use of lapply
body: <p>Someone sent me the following code, which repeats the same command (mvrnorm) 10 times, in a list format.</p>
  
  <pre><code>dat &lt;- lapply(1:10,mvrnorm, n = 10, Sigma=matrix(.3, 3, 3), mu = rep(0, 3))
  </code></pre>
  
  <p>The code works.  </p>
  
  <p>However, when I try the following command, it did not work and I do not understand why it does not work. I expect it to count the number of columns in 'x' ten times repeatedly:</p>
  
  <pre><code>dat &lt;- lapply(1:10, ncol, x=matrix(.3, 4, 4))
  
  Error in FUN(X[[i]], ...) : unused argument (X[[i]])
  </code></pre>
  
  <p>Basically, I am trying to understand in what situation the following format works:</p>
  
  <pre><code>lapply(1:10, function, ...)
  </code></pre>
  
  <p>If anyone can explain to me why it works when the function is <code>mvrnorm</code> (first example) but not <code>ncol</code> (second example)?</p>