How can I set a specific CRAN mirror permanently in R?
I want to set it permanently in my laptop so that when I do install.packages(), it won’t ask me again which mirror to choose.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can set repos in your .Rprofile to restore your choice every time you start R
Edit: to be more precise:
Add
to your .Rprofile, located in the home directory of your user.
You can find a list of CRAN mirrors here.
Example:
Alternatively, you can set the mirror site-wide in your
Rprofile.site. The location of the file is given by?Startup:So do
Sys.getenv("R_PROFILE")for the first option, orSys.getenv("R_HOME")orR.home()for the second option. On macOS, the location of the second is/Library/Frameworks/R.framework/Resources/etc/.The file may not exist, or you may see the following lines commented out :
So remove the comment marks and change "http://my.local.cran" to the correct website, e.g.: