R 更换Package安装源

有时候利用R安装R包,出现错误:


Warning in install.packages :

  unable to access index for repository https://cran.rstudio.com/src/contrib:

  cannot open URL 'https://cran.rstudio.com/src/contrib/PACKAGES'

Warning in install.packages :

  package ‘readxl’ is not available (for R version 3.4.1)


可能是因为国外的rstudio或者其他源链接不上,此时换成国内源即可解决问题,更换方法如下:

##1. 使用Rstudio

打开

tool -> Global options -> packages

##2. 使用终端

在使用终端命令行安装包的时候,可以直接指定源,命令如下:

install.packages(‘gdata’, repos = ‘https://mirrors.tuna.tsinghua.edu.cn/CRAN’)

##3. 更改配置文件

linux或mac系统下,安装速度过慢,更改为国内源方案,编辑~/.Rprofile, 指定国内CRAN源:

options(repos=structure(c(CRAN=“https://mirrors.tuna.tsinghua.edu.cn/CRAN/”)))

指定国内bioconductor源:

source(“http://bioconductor.org/biocLite.R”)

options(BioC_mirror=“http://mirrors.ustc.edu.cn/bioc/”)

biocLite(“clusterProfiler”)

通过Rprofile自定义函数:

source.bioconductor <- function(){

            source("http://bioconductor.org/biocLite.R")

            options(BioC_mirror="http://mirrors.ustc.edu.cn/bioc/")

}

通过调用source.bioconductor()函数,改变源并安装包

---------------------

作者:常玉俊bioinfo

来源:CSDN

原文:https://blog.csdn.net/chang349276/article/details/79295821

版权声明:本文为博主原创文章,转载请附上博文链接!

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 第十三期Day4 R语言初上手 豆豆花花 [生信星球](javascript:void(0);) 今天 准备工作 ...
    球球_180b阅读 2,803评论 0 1
  • 工欲善其事,必先利其器。总结一下,方便多了。R语言还是很牛逼的,可以干很多事情。有一把顺手的刀还是很重要的。 0....
    Liam_ml阅读 4,708评论 1 60
  • 刘小泽写于19.6.14-15-第二单元第二、三讲:获取Github代码包以及准备工作 笔记目的:根据生信技能树的...
    刘小泽阅读 2,833评论 1 10
  • 查看当前位置 getwd() getwd()[1] "/media/albert/0E3711AB0E3711AB...
    浩瀚之宇阅读 1,313评论 0 0
  • 普通: install.packages() 以前是: source("http://bioconductor.o...
    苏牧传媒阅读 6,544评论 0 2