title: Apply additional parameters syntax
body: <p>Let's say I have a data frame with columns of data, and I want to calculate the one-sided moving average of each column. Why does this work</p>
  
  <pre><code>my.rollapply &lt;- function(x){
  
      return(rollapply(x,moving.avg,FUN= mean, fill = NA,align = 'right', na.rm = TRUE))
  
  }
  
  averageData &lt;- apply(averageData, 2, my.rollapply)
  </code></pre>
  
  <p>but</p>
  
  <pre><code>averageData &lt;- apply(averageData, 2, rollapply, width = moving.avg, FUN = mean, fill = NA, align = 'right', na.rm = TRUE)
  </code></pre>
  
  <p>gives me an error of</p>
  
  <pre><code>Error in mean.default(newX[, i], ...) : 
    'trim' must be numeric of length one
  </code></pre>
  
  <p>Is this because mean itself requires additional parameters? How would I be able to pass in all the parameters to rollapply inside of apply then?</p>