title: Halt R script (run interactively) if a condition is not met
body: <p>Use case: I do interactive data analysis in RStudio, i.e. I highlight a bunch of code and hit run. Sometimes there are conditions that would statistically invalidate my analysis even though my code would still run fine. I want to stop the code or throw some very wild error in these cases.</p>
  
  <p>Minimal working example:</p>
  
  <pre><code>stopifnot(TRUE, FALSE)
  x &lt;- 42
  </code></pre>
  
  <p>If I highlight the two lines and run, <code>42</code> is still assigned to <code>x</code>. <em>That is bad</em> -- I don't want any line after <code>stopifnot(TRUE, FALSE)</code> to run (since they are statistically invalid, while programmatically fine).  Is there a way to stop the code totally if the condition is not met?</p>