R安装包源设置的常见方式及国内常用源

本文介绍了如何设置R安装包的源,特别是国内常用的CRAN镜像源,包括清华大学、北京外国语大学、中国科学技术大学等。通过在安装过程中指定源地址、命令行设置、RStudio中调整以及修改Rprofile.site文件,确保在国内快速稳定地安装R包。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

R安装包源设置的常见方式及国内常用源

目录

R安装包源设置的常见方式及国内常用源

国内CRAN源

安装中指定源地址

命令行设置镜像地址

Rstudio中设置镜像地址

修改Rprofile.site配置文件


国内CRAN源

https://mirrors.tuna.tsinghua.edu.cn/CRAN/TUNA Team, Tsinghua University
https://mirrors.bfsu.edu.cn/CRAN/Beijing Foreign Studies University
https://mirrors.ustc.edu.cn/CRAN/University of Science and Technology of China
https://mirror-hk.koddos.net/CRAN/KoDDoS in Hong Kong
https://mirrors.e-ducation.cn/CRAN/Elite Education
https://mirror.lzu.edu.cn/CRAN/Lanzhou University Open Source Society
https://mirrors.nju.edu.cn/CRAN/eScience Center, Nanjing University
https://mirrors.tongji.edu.cn/CRAN/Tongji University
https://mirrors.sjtug.sjtu.edu.cn/cran/Shanghai Jiao Tong University
https://mirrors.sustech.edu.cn/CRAN/Southern University of Science and Technology (SUSTech)

安装中指定源地址

# 安装包的过程中指定下载源地址

# install.packages("RCurl", repos='http://cran.us.r-project.org')
install.packages("RCurl", repos='https://mirrors.tuna.tsinghua.edu.cn/CRAN/')


****************************************************************

package 'RCurl' successfully unpacked and MD5 sums checked

The downloaded binary packages are in
	C:\Users\user\AppData\Local\Temp\Rtmpuccljh\downloaded_packages

命令行设置镜像地址

# 使用命令行设置镜像

#使用命令行设置镜像
options()$repos  
## 查看使用install.packages安装时的默认镜像
options()$BioC_mirror 
##查看使用bioconductor的默认镜像
options(BioC_mirror="https://mirrors.ustc.edu.cn/bioc/") 
##指定镜像,这个是中国科技大学镜像
options("repos" = c(CRAN="https://mirrors.tuna.tsinghua.edu.cn/CRAN/")) 
##指定install.packages安装镜像,这个是清华镜像

Rstudio中设置镜像地址

在Rstudio里面,Tool--Global Options--Packages选择China (Beijing) [https] - TUNA Team, Tsinghua University

修改Rprofile.site配置文件

R安装目录下R安装目录下\R\R-version\etc\Rprofile.site,找到Rprofile.site文件,打开该文件,找到下列语句找到Rprofile.site文件,打开该文件,找到下列语句

# set a CRAN mirror
# local({r <- getOption("repos")
#       r["CRAN"] <- "http://my.local.cran"
#       options(repos=r)})
修改如下:


# set a CRAN mirror 
local({r <- getOption(“repos”) 
r[“CRAN”] <- “http://mirrors.tuna.tsinghua.edu.cn/CRAN/” 
options(repos=r)}

参考:R包安装设置清华镜像的三种方法
参考:Cannot install R packages in Jupyter Notebook
参考:Setup Jupyter Notebook for R
参考:How do I set a CRAN mirrror to install an R package in Jupyter?
参考:How to install R packages that are not available in “R-essentials”?
参考:R包安装镜像设置为清华安装镜像

参考:https://cran.r-project.org/mirrors.html

参考:国内开源镜像站点汇总[超级多]

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Data+Science+Insight

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值