简体   繁体   English

r install.packages安装下载的包

[英]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. install.packages(ask = FALSE)下载包,但是如果有错误,它会中止。 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 我正在使用Debian Stable Linux和backports存储库,如上所述: 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. 这个答案适用于Linux系统,虽然我认为对于Windows而言,事情应该不同。 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. 当您尝试安装软件包时,在过程结束时(无论是否成功),R会告诉您下载的软件包在哪里。 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; R将源包存储在临时文件夹中; 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: 当我尝试安装R包时,我可以:

   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)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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