title: How to use apply() with a function that takes more than one input?
body: <p>I have a 10 x 5 data frame and a function that receives 2 inputs <code>a</code> and <code>b</code>.</p>
  
  <p><code>a</code> is a vector and <code>b</code> is an integer.</p>
  
  <p>The function <code>fun</code> calculates the mean of the vector <code>a</code> and multiplies it by <code>b</code> and returns the result. In the following code, I try to <code>apply()</code> this function to every column of <code>x</code> but it does not seem to work. Help, please!</p>
  
  <pre><code>x = data.frame(rnorm(10), rnorm(10), rnorm(10), rnorm(10), rnorm(10))
  
  fun = function(a, b)
  {
    c = mean(a) * b
    return(c)
  }
  
  apply(x, 2, fun(x,2))
  </code></pre>