title: how to pass arguments as a list in R function
body: <p>I have functions that has a lot of arguments. So I would like to create a list of arguments and pass them to the function.</p>
  <p>As an example, take <code>?mean</code> function:</p>
  <pre class="lang-r prettyprint-override"><code>mean(x, trim = 0, na.rm = FALSE, ...)
  </code></pre>
  <p>So lets say I want to calculate mean of <code>1:10</code>, assigned to variable <code>x</code>, but pass other arguments as a list:</p>
  <pre class="lang-r prettyprint-override"><code>gm &lt;- list (trim = 0, na.rm = FALSE)
  
  mean(1:10, gm)
  #R&gt; Error in mean.default(1:10, gm) : 'trim' must be numeric of length one
  </code></pre>
  <p>I tried to use <code>do.call</code> but do not work either.</p>
  <pre class="lang-r prettyprint-override"><code>do.call(mean,list(1:10, gm))
  #R&gt; Error in mean.default(1:10, list(trim = 0, na.rm = FALSE)) : 
  #R&gt;   'trim' must be numeric of length one
  </code></pre>