title: How to compare functions?
body: <p>Is there a way to compare whether two function objects are the same?</p>
  
  <pre><code>m &lt;- mean
  m == mean ## don't work
  
  ## this seems not to be the correct way:
  functionBody(mean)==functionBody(m)
  </code></pre>
  
  <p><em>EDIT</em>: Some more details. I have a function with two arguments (a matrix and a user-defined function which is applied columnwise, e.g. mean, median, ...). If the function is <code>mean</code> I want to use <code>colMean</code> instead (to save some running time).</p>
  
  <pre><code>foo &lt;- function(m, fun) {
    #if (fun==mean) {
    #  return(colMeans(m));
    #} else {
      return(apply(m, 2, fun));
    #}
  }
  </code></pre>