简体   繁体   中英

r install.packages to install downloaded packages

I am trying to install and update packages. install.packages(ask=FALSE) downloads the packages but if there is an error, it aborts. If I run it again, it again downloads the packages. How can it check and install already downloaded packages on repeat running rather than downloading every time?

I am using Debian Stable Linux with backports repository, as mentioned on : http://cran.r-project.org/bin/linux/debian/README

This answer is for a linux system, although I think that for windows things shouldn't be different. When you try to install a package, at the end of the process (whether successful or not), R tells you where is the downloaded package. You should see something like this:

    #The downloaded source packages are in
    #       ‘/tmp/RtmpSPFiKl/downloaded_packages’

The path may change on a case basis. R stores the source packages in a temporary folder; this means that next time you reboot, files will disappear. So, suppose that I was trying to install a package that needs some system requirements. I receive an error. Then I proceed to install the needed system packages. When I try to install the R package back, I can:

   install.packages("/tmp/RtmpSPFiKl/downloaded_packages/packagename.tar.gz",repos=NULL)

without having to download it a second time.

您可以使用destir参数并将repos设置为NULL

install.packages("RcppEigen",destdir = '/tmp/RtmpWq9e8P/downloaded_packages',repos=NULL)

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