title: R: Passing parameters from a wrapper function to internal functions
body: <p>I am not surprised that this function doesn't work, but I cannot quite understand why.</p>
  
  <pre><code>computeMeans &lt;- function(data,dv,fun) {
      x &lt;- with(data,aggregate(dv,
          list(
              method=method,
              hypo=hypothesis,
              pre.group=pre.group,
              pre.smooth=pre.smooth
          ),
          fun ) )
      return(x)
  }
  
  computeMeans(df.basic,dprime,mean)
  </code></pre>
  
  <p>Where <code>df.basic</code> is a dataframe with factors <code>method</code>, <code>hypothesis</code>, etc, and several dependent variables (and I specify one with the <code>dv</code> parameter, dprime).  </p>
  
  <p>I have multiple dependent variables and several dataframes all of the same form, so I wanted to write this little function to keep things "simple".  The error I get is:</p>
  
  <pre><code>Error in aggregate(dv, list(method = method, hypo = hypothesis, 
  pre.group = pre.group,  : 
      object 'dprime' not found
  </code></pre>
  
  <p>But dprime does exist in df.basic, which is referenced with <code>with()</code>.  Can anyone explain the problem? Thank you!</p>
  
  <p>EDIT: This is the R programming language. <a href="http://www.r-project.org/" rel="nofollow">http://www.r-project.org/</a></p>