脱机安装R软件包 [英] Offline Installation of R packages
问题描述
我的研究所使用代理服务器,没有人能够以通常的方式安装软件包. (即从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屋!