1.下載Forecast包以及其依賴包,執行下面R腳本;web
getPackages <- function(packs){ packages <- unlist( tools::package_dependencies(packs, available.packages(),which=c("Depends", "Imports"), recursive=TRUE) ) packages <- union(packs, packages) packages } myPackages <- c("forecast","RcppArmadillo") packages <- getPackages(myPackages) download.packages(packages, destdir="E:/Rpackages/", type="source")
2.下載完成以後,將Rpackages壓縮爲Rpackages.tar.gz,上傳到centos並解壓;centos
3.下載stringi依賴的數據包icudt61l.zip(不一樣的stringi可能會有不一樣的版本,能夠從報錯信息裏面提取下載路徑),下載,下載完成以後,直接將壓縮包上傳到centos中;url
4.安裝stringi,在centos中輸入R,進入R命令模式(指定數據集所在本地位置,不然會報錯installation of package ‘stringi’ had non-zero exit status)spa
install.packages("包所在路徑/stringi_1.4.3.tar.gz",configure.vars="ICUDT_DIR=icudt61l.zip上一級路徑", repos = NULL, type = "source")
5.安裝RcppArmadillo,RcppArmadillo_0.9.500.2.0要求R語言環境在3.3.0以上code
install.packages("路徑/Rcpp_1.0.1.tar.gz", repos = NULL, type = "source") install.packages("路徑/RcppArmadillo_0.9.500.2.0.tar.gz", repos = NULL, type = "source")
5.安裝forecast,按順序輸入如下指令,等待安裝完成便可。ip
# 忽略>,依次輸入>後腳本 >library(tools) >path <- "下載的離線包解壓後路徑" >write_PACKAGES(path,type="source") >myPackages <- c("forecast") >install.packages(myPackages, contriburl=paste("file:",path,sep=''),type="source")
附註:ci
安裝過程當中,若是出現had non-zero exit status錯誤,從新安裝便可。get
單個包下載路徑:https://cran.r-project.org/src/contrib/Archive/stringi/源碼
包依賴查詢路徑:https://cran.r-project.org/web/packages/stringi/string
R語言源碼包:https://cran.r-project.org/src/base/R-3/