title: Error R Studio Knit HTML with install.packages line
body: <p>I am a new user to RStudio, and have encountered an error when using a .rmd file and Knit HTML</p>
  
  <p>If I have an install.packages line:</p>
  
  <pre><code>install.packages('ggplot2');
  library(ggplot2);
  </code></pre>
  
  <p>when I click Knit HTML, an error is returned:</p>
  
  <blockquote>
    <p>Error in contrib.url(repos, "source") : trying to use CRAN without
    setting a mirror calls: ... withVisible -> eval -> eval ->
    install.packages -> contrib.url Execution halted</p>
  </blockquote>
  
  <p>I was able to work around this using:</p>
  
  <pre><code>if (!require('ggplot2')) 
  {
    install.packages('ggplot2');
    library(ggplot2);
  }
  </code></pre>
  
  <p>If I'm writing a .rmd, do I need to use the <code>if (!require(</code> line every time I install a new package? Is there a way to avoid this so I can write <code>install.packages(</code> only?</p>