last day (15 days later) » 

5:40 PM
1
Q: install.packages() enforce no CRAN mirror selection?

user5783745When running install.packages("somepackage") from terminal, the pop out gui to select a CRAN mirror can be inconvenient and somewhat unnecessary. Is there a way to call install.packages("somepackage") (from R in the terminal) so as to avoid having to select a mirror via the gui, but doesn't req...

 
Correct me if I'm wrong but what you want is using install.packages() without naming a mirror so R is choosing the appropriate mirror itself?
 
@Gainz yes perfect
 
@Roland I mean in Canada R will most likely not use the Taiwan mirror of the Cran.
 
@Roland any mirror is good. I usually select one geographically close to me, but to save 0.5 seconds (through faster download speed), it's hardly worth messing around outside the terminal and reading the sentence asking for selection
 
@user5783745 Try using the following url : https://cloud.r-project.org.
Like this : install.packages("names", repos = "https://cloud.r-project.org") from what I read it should give you a mirror that is close to you most of the timeé
 
5:40 PM
@Gainz we could put any mirror's url in the repos option but ideally I would like to not to have to know a CRAN mirror off the top of my head
@Roland is there any way to select the first without the gui opening and selecting, as in, using code (and conveniently). E.g. something like install.packages("names", repos = NULL) (<- that doesn't work, just an example of what would be nice)
 
@user5783745 The url I gived you gives a mirror that is close to you (or at least one that is always going to be near).
 
@Gainz ah I see. That's helpful. Any way to do that without having to remember a url? `repos = 'chooseforme' would be handy
@Gainz I thought install.packages("names", repos = chooseCRANmirror()) would do as desired, but even it requires (manual) selection from a list it presents
 
@user5783745 Yes because that function return a list of the available mirrors. Can I know why you can't just add manually the name of the cloud mirror or select 1 when using chooseCRANmirrors()?
 
@Gainz, to be honest, because I won't remember it when I need it
@Gainz not that install.packages("names", repos = getCRANmirrors()$URL[1]) is much more memorable
 
@user5783745 Yes it is the same thing! I simply wanted to put the repos's link but you could use this without any problem.
 
5:40 PM
@Gainz I was hoping for something shorter and more easily remembered than both install.packages("names", repos = "https://cloud.r-project.org") and install.packages("names", repos = getCRANmirrors()$URL[1]). ideally something like install.packages("names", repos ="best"), but it sounds this is not possible so your solution and a slightly simpler version of Tom's are best
 
@user5783745 See my answer, thats the only way I know of setting it "automatically" but you will need to modify your .Rprofile file.
 

last day (15 days later) »