简体   繁体   English

脱机安装R软件包

[英]Offline Installation of R packages

My institute uses proxy server, and no one is able to install packages in a usual way. 我的研究所使用代理服务器,没有人能够以通常的方式安装软件包。 (ie downloading binary file from CRAN and then choosing Mirro and the installing etc etc). (即从CRAN下载二进制文件,然后选择Mirro和安装等)。

I am able to install packages if I use internet outside of my institute. 如果我在学院以外使用互联网,则可以安装软件包。

So, I am looking for an offline way to install packages. 因此,我正在寻找一种离线安装软件包的方法。 Please provide a detailed solution, I have just started using R. 请提供详细的解决方案,我刚刚开始使用R。

Before writing this question I did look at this earlier asked question but did not quite understand the terms which have been used here (they are very direct). 在写这个问题之前,我确实看过这个较早提出的问题,但是不太了解这里使用的术语(它们非常直接)。 I am a newbie, please provide me a detailed solution. 我是新手,请为我提供详细的解决方案。 Offline install of R package and dependencies 脱机安装R软件包和依赖项

Help will really be appreciated. 帮助将不胜感激。 I am really stuck here. 我真的被困在这里。 I am not able to do anything. 我无能为力。

Thank you. 谢谢。

This is my work around. 这是我的工作。 Might be helpful for you too. 可能对您也有帮助。

Idea: Download packages with their dependencies through internet and install packages offline. 想法:通过Internet下载软件包及其依赖项,然后离线安装软件包。

# Set Mirror to download packages    
options(repos=structure(c(CRAN="http://cran.ma.imperial.ac.uk/")))

 # Set Working Directory   
    setwd(file.path(
        "D:"
      , "User"
      , "DownloadingPackagesWithDependencies"
      )
      )


getPackages <- function(packs){
  packages <- unlist(
      tools::package_dependencies(
          packs
        , available.packages()
        , which=c("Depends", "Imports")
        , recursive=TRUE
        )
      )
    packages <- union(packs, packages)
    packages
  }

# Specify Packages to Download with their dependencies also   
Packages <- getPackages(
                c(
                  "ggplot2"
                  )
                )


download.packages(
    pkgs=Packages
  , destdir=getwd()
  , type="source")

# Install packages from local drive
    install.packages(
        pkgs="ggplot2_0.9.3.1.tar.gz"
      , repos = NULL
      , type="source"
       )

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

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