title: traceback() for interactive and non-interactive R sessions
body: <p>I observed a different between an interactive and non-interaction R session about <code>traceback()</code> which I do not understand. For the code below, it will produce an error, but in an interactive R session, I can see the traceback information, whereas if I save the code to <code>test.R</code> and call it via <code>Rscript test.R</code> or <code>R -f test.R</code>, I can no longer see the traceback:</p>
  
  <pre><code>f = function() {
    on.exit(traceback())
    1 + 'a'
  }
  f()
  </code></pre>
  
  <p>In an interactive R session:</p>
  
  <pre><code>&gt; f = function() {
  +   on.exit(traceback())
  +   1 + 'a'
  + }
  &gt; f()
  Error in 1 + "a" : non-numeric argument to binary operator
  1: f()
  </code></pre>
  
  <p>Non-interactive execution:</p>
  
  <pre><code>$ Rscript test.R 
  Error in 1 + "a" : non-numeric argument to binary operator
  Calls: f
  No traceback available 
  Execution halted
  </code></pre>
  
  <p>I did not see an explanation in <code>?traceback</code>, and I'm wondering if there is a way to enable traceback for non-interactive R sessions. Thanks!</p>