title: In R, how to use a "null" default value for an argument of a function?
body: <p>Here is my current code:</p>
  
  <pre><code>my.function &lt;- function( my.arg="" ){
    if(my.arg == "")
      my.arg &lt;- rnorm(10)
    return( mean(my.arg) )
  }
  </code></pre>
  
  <p>It returns me this:</p>
  
  <pre><code>&gt; my.function( rbinom(10, 100, 0.2) )
  [1] 18.5
  Warning message:
  In if (a == "") a &lt;- rnorm(10) :
    the condition has length &gt; 1 and only the first element will be used
  </code></pre>
  
  <p>I tried with <code>my.arg=c()</code>, or <code>my.arg=0</code>, but I always get either a warning or an error. And the R manual doesn't say much on this issue.</p>
  
  <p>Any idea? Thanks in advance!</p>