title: how to pass optional arguments to function inside do.call
body: <p>I wish to programmatically create an array of variable names such as:</p>
  
  <pre><code>desired_output &lt;- c("first_purchase_date","last_purchase_date","largest_purchase_date",
                      "first_purchase_amount","last_purchase_amount","largest_purchase_amount") 
  </code></pre>
  
  <p>I believe I can do this with <code>do.call</code>, building on something like:</p>
  
  <pre><code>&gt; do.call(paste, expand.grid(c("first","last","largest"),c("date","amount")))
  [1] "first date"     "last date"      "largest date"   "first amount"   "last amount"    "largest amount"
  </code></pre>
  
  <p>However I can't quite figure out how to pass the <code>sep="_purchase_"</code> argument to <code>paste</code> within <code>do.call</code>.  In <code>?do.call</code> I read that </p>
  
  <blockquote>
    <p><code>args</code> is a <em>list</em> of arguments to the function call.  The <code>names</code>
    attribute of <code>args</code> gives the argument names.</p>
  </blockquote>
  
  <p>Attempting to incorporate this, I have tried:</p>
  
  <pre><code>df &lt;- expand.grid(c("first","last","largest"), 
                    c("date","amount"), 
                    stringsAsFactors = FALSE)
  
  do.call(paste, args = list(...=df, sep="_purchase_"))
  # does not return desired output, but instead:
  # [1] "c(\"first\", \"last\", \"largest\", \"first\", \"last\", \"largest\")"
  # [2] "c(\"date\", \"date\", \"date\", \"amount\", \"amount\", \"amount\")"  
  </code></pre>
  
  <p>What is the correct way to produce <code>desired_output</code> via <code>do.call</code>?</p>