title: Stop and return object within function without reporting error
body: <p>I am trying to figure out how to return an object if an if statement is TRUE from a function <code>foo</code> within a  parent function <code>bar</code>, and not execute following code in <code>bar</code>; or if FALSE, execute the following code in <code>bar</code>. In the function <code>bar2</code> below I can test the output of <code>foo</code> and then execute more code in <code>bar2</code> if the output of <code>foo</code> is NULL. However, in trying to reduce lines of code used, I want to know if I can somehow prevent "howdy" from printing in the <code>bar</code> function if the if statement in the function <code>foo</code> is TRUE.  <code>stop</code> would do it but is signals an error, which is not what is happening here. Basically I'm looking for an equivalent of <code>stop</code> but returning an object w/o error. </p>
  
  <pre><code>foo &lt;- function(x){
    if(x &lt; 10){
      "hello world"
    } else
    { NULL }
  }
  
  bar &lt;- function(y){
   foo(y)
   "howdy"
  }
  
  bar2 &lt;- function(y){
    out &lt;- foo(y)
    if(!is.null(out)){
      out
    } else
    {
      "howdy"
    }
  }
  
  bar(5)
  [1] "howdy"
  
  bar2(5)
  [1] "hello world"
  </code></pre>