如何在R中永久设置特定的CRAN mirror?
我想把它永久地放在我的笔记本电脑上,这样当我做install.packages()
次时,它就不会再问我要 Select 哪个镜子了.
如何在R中永久设置特定的CRAN mirror?
我想把它永久地放在我的笔记本电脑上,这样当我做install.packages()
次时,它就不会再问我要 Select 哪个镜子了.
您可以在.Rprofile中设置repos,以便在每次启动R时恢复您的 Select
Edit:更准确地说:
添加
options(repos=structure(c(CRAN="YOUR FAVORITE MIRROR")))
.Rprofile美元
或者,您可以在Rprofile.site
中设置镜像站点的宽度.文件的位置由?Startup
给出:
这个
第一个选项是Sys.getenv("R_PROFILE")
,第二个选项是Sys.getenv("R_HOME")
或R.home()
.在macOS上,第二个的位置是/Library/Frameworks/R.framework/Resources/etc/
.
该文件可能不存在,或者您可能会看到以下几行被注释掉:
# set a CRAN mirror
# local({r <- getOption("repos")
# r["CRAN"] <- "http://my.local.cran"
# options(repos=r)})
因此,请删除 comments 标记,并将"http://my.local.cran"改为正确的网站,例如:
local({r <- getOption("repos")
r["CRAN"] <- "http://cran.r-project.org"
options(repos=r)})