title: Overwrite arguments within a function
body: <p>I have a function that allows a lot of arguments, and to make things easier I decided to include another variable where arguments are introduced as a list (named <code>args</code> in the example below).</p>
  
  <pre><code>foo &lt;- function(x, a, b, c, args, ...) {
  
  ifelse(missing(a)==TRUE, a&lt;-1, NA)
  ifelse(missing(b)==TRUE, b&lt;-2, NA)
  ifelse(missing(c)==TRUE, c&lt;-3, NA)
  
  if(missing(args)==FALSE) {
  for(i in 1:length(args)) {
      tmp &lt;- as.vector(args[[i]])
      assign(names(args)[i], get("tmp"))
  }
  }
  
  # Need something that overwrites "args" when the 
  # other arguments are specified
  
  print(list(x=x, a=a, b=b, c=c))
  
  }
  </code></pre>
  
  <p>And the function <code>foo</code> gives the following:</p>
  
  <pre><code>foo(0)
  $x
  [1] 0
  
  $a
  [1] 1
  
  $b
  [1] 2
  
  $c
  [1] 3
  </code></pre>
  
  <p>Here <code>my_args</code> records the profile arguments.</p>
  
  <pre><code>my_args &lt;- list(a=1, b=1, c=1)
  </code></pre>
  
  <p>to produce:</p>
  
  <pre><code>foo(0, args=my_args)
  $x
  [1] 0
  
  $a
  [1] 1
  
  $b
  [1] 1
  
  $c
  [1] 1
  </code></pre>
  
  <p><br /> </p>
  
  <p>I would like to find a way to overwrite values in <code>args</code> whenever the corresponding arguments are specified in the function. Although the user specified two different values for the same argument, there are circumstances in which this makes sense. </p>
  
  <p>For instance, </p>
  
  <pre><code>foo(0, args=my_args, c=3)
  $x
  [1] 0
  
  $a
  [1] 1
  
  $b
  [1] 1
  
  $c
  [1] 3
  </code></pre>
  
  <p>And this is to see what happens when <code>c=3</code> within the profile recorded in <code>my_args</code>.</p>
  
  <p>I appreciate very much some help.</p>