R包的离线安装 [英] Offline Installation of R packages

查看:16
本文介绍了R包的离线安装的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的研究所使用代理服务器,没有人能够以通常的方式安装软件包.(即从 CRAN 下载二进制文件,然后选择 Mirro 和安装等).

My institute uses proxy server, and no one is able to install packages in a usual way. (i.e downloading binary file from CRAN and then choosing Mirro and the installing etc etc).

如果我在学院外使用互联网,我可以安装软件包.

I am able to install packages if I use internet outside of my institute.

所以,我正在寻找一种离线方式来安装软件包.请提供详细的解决方案,我刚开始使用R.

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

我们将不胜感激.我真的被困在这里了.我什么都做不了.

Help will really be appreciated. I am really stuck here. I am not able to do anything.

谢谢.

推荐答案

这是我的工作.可能对你也有帮助.

This is my work around. Might be helpful for you too.

想法:通过互联网下载包及其依赖项并离线安装包.

Idea: Download packages with their dependencies through internet and install packages offline.

# 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"
       )

这篇关于R包的离线安装的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆