Error R Studio Knit HTML with install.packages line
I was also getting same error while using the Knit document and I did below things in the R script :
-
Run the command in console to set your default repository :
options(repos=structure(c(CRAN=”http://cran.r-project.org”))) -
Add the below code in your R studio :
options(repos=”https://cran.rstudio.com” ) -
Add the url reference for packages needed, for example :
install.packages(“pscl”, repos = “cran.rstudio.com“)
You don’t need install.package()
line everytime.
Normally you should install packages in console or a separate interactive session or delete that line after installation of that library (here it’s ggplot).
Just use library(ggplot2)
Hope it helps
Read more here: Source link