title: how do I make install.packages return an error if an R package cannot be installed?
body: <p><code>install.packages()</code> returns a warning if a package cannot be installed (for instance, if it is unavailable); for example:</p>
  
  <pre><code>install.packages("notapackage")
  </code></pre>
  
  <p>(<strong>EDIT</strong>: I'd like to throw an error regardless of the reason the package cannot be installed, not just this example case of a missing package).</p>
  
  <p>I am running the <code>install.packages</code> command in a script, and I would like it to trigger a proper error and exit execution.  I don't see an obvious option inside <code>install.packages</code> for handling this behavior.  Any suggestions?</p>