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 :

  1. Run the command in console to set your default repository :

  2. Add the below code in your R studio :
    options(repos=”” )

  3. Add the url reference for packages needed, for example :
    install.packages(“pscl”, repos = ““)

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