I am a new RStudio user and encountered an error while using .rmd and Knit HTML file
If I have the install.packages line:
install.packages('ggplot2'); library(ggplot2);
when I click the "Knit HTML" button, an error is returned:
Error in contrib.url (repos, "source"): attempt to use CRAN without setting mirror calls: ... withVisible â eval â eval â install.packages â contrib.url Execution is paused
I managed to get around this using:
if (!require('ggplot2')) { install.packages('ggplot2'); library(ggplot2); }
If I write .rmd, I need to use the line if (!require( every time I install a new package? Is there a way to avoid this, so I can write install.packages( only?
source share