简体   繁体   中英

Understanding install.packages() behaviour re repos and dependencies

I (finally) just installed ggplot2 by doing it from R directly and turning off antivirus. (It had previously failed out on moving the temp files for stringi and magrittr, so I followed the advice in StackOverflow .)

And it worked. But I have a few puzzles about its behaviour. The command I used was:

install.packages("ggplot2", repos = getOption("repos"), dependencies = TRUE)

Two things that happened as a result puzzled me:

  • it didn't ask me what repos I wanted to use - but just went to imperial (which is fine with me)

  • it didn't install the dependencies - which I discovered when I did
    library, so I installed the missing ones manually one by one (luckily there were only two - the two that had failed out when I had tried an install from RStudio with my antivirus on)

I have read the documentation on install.packages() but haven't understood it, as both these behaviours were different from what I expected. I thought I would get a query about what repos to go to, and I thought I would get the dependencies tagging along on the install.

Can someone explain?

Thanks.

It always install dependencies. That is the whole point of

  1. having repos -- and why CRAN was so important over these 20 years, and
  2. declaring dependencies in DESCRIPTION .

Now, I set my repos in the startup file ( Rprofile.site in my case, see help(Startup) and its examples section for how). You can also just call options() before calling install.packages() . The dependencies=TRUE is also superfluous.

But thinks you need to check and did not tell us: source or binary installation? What OS? What is your R version and does it mesh with what the repos expect -- a current version on R?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM