title: ifelse not working properly
body: <p>Inside a function, I want to set a variable to either the corresponding argument, or a default value if that argument is NULL. The code is as follows:</p>
  
  <pre><code>  rcontrol &lt;- ifelse(is.null(rcontrol),rpart.control(cp=0.001,minbucket=100,minsplit = 5),rcontrol)
  </code></pre>
  
  <p>It took me a long time to figure out that the <code>rcontrol</code> isn't the same as if it were defined in this way:</p>
  
  <pre><code>rcontrol &lt;- rpart.control(cp=0.001,minbucket=100,minsplit = 5)
  </code></pre>
  
  <p>Can anyone please explain this bizarre behavior of <code>ifelse</code>?</p>