Hi,
My r markdown won't knit to html. It keeps giving me this message.
Seems to imply it has an issue with some of the packages installed for running linear regression (lm, car, sandwich) I don't know what to do about it. Please help me.
this is the messeg it gives me
Quitting from lines 21-35 (Assignment.Rmd)
Error in contrib.url(repos, "source") :
trying to use CRAN without setting a mirror
Calls: ... withVisible -> eval -> eval -> install.packages -> contrib.url
Execution halted
here's the code chunk from line 21-35
library(tidyverse)
install.packages('lmtest')
library(lmtest)
install.packages ("car", dependencies=TRUE)
library(car)
install.packages ("sandwich")
library(sandwich)
Kindly assist in resolving this please.
Thanks
M
It means you don't have a CRAN url setup in your R session. Usually you install package interactively and you get a windows to choose the CRAN mirror to use. This can't happen in a non interactive session. A repository url must be set in this case.
I advice to not install packages in a R Markdown document. Usually packages are there before and are to be installed by the user directly, not your document. Also, this will try to install each time the packages even if there are already installed. That is how install.packages() works.
If you still want not to follow this advice, just set a repos = in the call to install.packages or set the options repos options(repos= ...) -