R语言包在线安装so happy,离线安装so hard,尤其是解决依赖问题….
在R的控制台,输入
# 安装 gridExtra
install.packages("gridExtra")
# 安装 stepNorm
install.packages("stepNorm", contriburl="http://www.your.url", dependencies = TRUE) #
# 指定安装目录
install.packages("stepNorm", contriburl="http://www.your.url", lib="mydir")
下载package.tar.gz文件:传送门
在Shell终端(注意不是R)输入:
R CMD INSTALL package.tar.gz
参考文章:R语言离线下载包和依赖
下载包和依赖到本地目录下
#download
getPackages <- function(packs){
packages <- unlist(
tools::package_dependencies(packs, available.packages(),which=c("Depends", "Imports"), recursive=TRUE)
)
packages <- union(packs, packages)
packages
}
myPackages <- c("dplyr","sqldf","DBI","rJava","RJDBC","forecast","lubridate","xgboost","ggplot2","plyr")
packages <- getPackages(myPackages)
download.packages(packages, destdir="/home/zhenggang/R", type="source")
把包和依赖传入离线环境后,离线安装
#install
library(tools)
path <- "/home/zhenggang/R"
write_PACKAGES(path,type="source")
myPackages <- c("dplyr","sqldf","DBI","rJava","RJDBC","forecast","lubridate","xgboost","ggplot2","plyr")
install.packages(myPackages, contriburl=paste("file:",path,sep=''),type="source")
报错:
checking whether we can fetch icudt… downloading the ICU data library (icudt)
解决方法:
手动下载一个master版本的,包含这个坑爹的包….
https://raw.githubusercontent.com/gagolews/stringi/master/INSTALL
Package ‘qvalue’ was removed from the CRAN repository.
Formerly available versions can be obtained from the archive.
This package is now available from Bioconductor only, see http://www.bioconductor.org/packages/release/bioc/html/qvalue.html
官网地址:传送门。
按照方法请参考:R编译安装教程