title: R: how to make passing of arguments using ... to multiple functions well-defined?
body: <p><strong>V1</strong>: Suppose functions <code>f(x, ...)</code> and <code>g(x , ...)</code> can be passed different arguments. If I were to define a new function using both of them, can I make the passing of arguments via the <code>...</code> operator well-defined? As a simple example:</p>
  
  <pre><code>f1 = function(x, n = 1) x + n
  g1 = function(x, m = 1) x + m
  f  = function(x, ...) f1(x, ...)
  g  = function(x, ...) g1(x, ...)
  
  h = function(x, ...) {
  
    fgList = list()
    fgList[["f"]] = f(x, ...)
    fgList[["g"]] = g(x, ...)
    return(fgList)
  }
  
  h(1:4)
  #  $f
  #  [1] 2 3 4 5
  
  #  $g
  #  [1] 2 3 4 5
  
  h(1:4, n = 2)
  #  Error in g1(x, ...) : unused argument (n = 2)
  </code></pre>
  
  <p>The argument <code>n</code> is being passed down to functions <code>f</code> and <code>g</code>, but it is only well-defined for function <code>f</code>. I want to mitigate against this.</p>
  
  <p><strong>V2:</strong> If they are functions that I have defined, then Hong Ooi's solution below works perfectly. </p>
  
  <p>Can this solution be extended for pre-defined functions which don't have a <code>...</code> argument or equivalently, can a <code>...</code> argument be 'added' to a predefined function which doesn't have one? For example:</p>
  
  <pre><code>h = function(x, ...) mean(x, ...) * median (x, ...)
  h(1:4, test = 1)
  ##  Error in median(x, ...) : unused argument (test = 1)
  </code></pre>