Select CRAN Mirror in R (2 Examples) | Manually Specify Repository
In this article, I’ll illustrate how to select a repository manually when installing an add-on package in the R programming language.
The page contains these topics:
Let’s dive right into the examples:
Example 1: R Message – Please select a CRAN mirror for use in this session
Let’s assume that you want to install a new package in R:
install.packages("dplyr") # Try to install dplyr package # --- Please select a CRAN mirror for use in this session --- |
install.packages("dplyr") # Try to install dplyr package # --- Please select a CRAN mirror for use in this session ---
Then, it might happen that the message “Please select a CRAN mirror for use in this session” is printed to the RStudio console. (It didn’t happen to me when I ran the previous code… However, it might happen.)
What should you do in this case? That’s what I’ll explain next…
Example 2: Manually Specify Repository when Installing a Package in R
In case you are seeing the message “Please select a CRAN mirror for use in this session” after trying to install a package, you might change the repository manually.
You can find a list of available CRAN mirrors here. Select one of these mirrors and specify it in character string format as repos within the install.packages function:
install.packages("dplyr", # Using repos argument repos = "https://cran.uni-muenster.de/") |
install.packages("dplyr", # Using repos argument repos = "https://cran.uni-muenster.de/")
Now, the installation of the package should work without any problems.
Video, Further Resources & Summary
Have a look at the following video which I have published on my YouTube channel. I show the topics of this tutorial in the video tutorial:
The YouTube video will be added soon.
Furthermore, you may want to read the other articles of my website.
To summarize: You learned in this tutorial how to install.packages(“dplyr”, repos = “https://cran.uni-muenster.de/”) in R. If you have any further questions, don’t hesitate to let me know in the comments.