若是是默認的R安裝通常會很慢html
install.packages(pkgs, lib, repos = getOption("repos"), contriburl = contrib.url(repos, type), method, available = NULL, destdir = NULL, dependencies = NA, type = getOption("pkgType"), configure.args = getOption("configure.args"), configure.vars = getOption("configure.vars"), clean = FALSE, Ncpus = getOption("Ncpus", 1L), verbose = getOption("verbose"), libs_only = FALSE, INSTALL_opts, quiet = FALSE, keep_outputs = FALSE, ...) install.packages("ABC",repos="http://mirror.bjtu.edu.cn/ "),換成北大的鏡像或者清華鏡像應該都會很快 若是想永久設置,就用options修改便可。
bioconductor其實也是有鏡像的函數
source("http://bioconductor.org/biocLite.R") options(BioC_mirror="http://mirrors.ustc.edu.cn/bioc/") biocLite("RGalaxy")##這樣就用中科大的鏡像來下載包啦 ## bioconductor還有不少其它鏡像:https://www.bioconductor.org/about/mirrors/ ##https://stat.ethz.ch/R-manual/R-devel/library/utils/html/chooseBioCmirror.html options(BioC_mirror="https://mirrors.tuna.tsinghua.edu.cn/bioconductor") options("repos" = c(CRAN="https://mirrors.tuna.tsinghua.edu.cn/CRAN/"))
1.調用chooseCRANmirror函數: > chooseCRANmirror() R會顯示CRAN鏡像的列表。 2.從列表中選擇鏡像並點擊肯定。 3.經過查看repos選項的第一個元素來獲取所選鏡像的URL地址: > options("repos")[[1]][1] 4.將下面的命令添加至.Rprofile 文件中: options(repos="URL") 其中的URL就是鏡像的URL。 討論 在每次安裝R包的過程當中都會使用相同的CRAN鏡像(即離本地最近的鏡像地址)。你可能對於R重複地詢問選擇鏡像感到厭煩。按照上述方法所給出的解決方案進行操做,便設定了默認的鏡像,R每次就再也不詢問了。 repos選項是默認鏡像的名稱。使用chooseCRANmirror函數選擇鏡像時會有一個重要的反作用,即按照選擇來設定repos選項。問題是當R退出時,R不會保存選擇的鏡像爲默認鏡像。經過在.Rprofile中對repos進行設定,R在啓動時會自動恢復你的設定。