美文网首页
R安装升级后的若干规定动作

R安装升级后的若干规定动作

作者: 思考问题的熊 | 来源:发表于2018-08-23 11:30 被阅读218次

两个地址

R cran 镜像地址 https://cran.r-project.org/mirrors.html

bioconductor mirror 地址 https://www.bioconductor.org/about/mirrors/

第一步:给R包一个家

通过 Renviron 文件为R自身设置一些环境变量,仅对R有效。

file.edit('~/.Renviron') 打开文件

R_LIBS_USER="E:/Rlib"
# 指定R的附加包安装目录

第二步:给R包指两条路

.Rprofile文件在R启动时会被首先执行。

file.edit('~/.Rprofile') 打开文件

在文件末尾添加两行

options(BioC_mirror="https://mirrors.ustc.edu.cn/bioc/")
#bioconductor

options("repos" = c(CRAN="https://mirrors.tuna.tsinghua.edu.cn/CRAN/",
    CRANextra = "http://www.stats.ox.ac.uk/pub/RWin"))
#cran

如果上面两步设置好后在安装bioconductor 还有问题,可以再用第三步。

第三步:安装 BiocInstaller

https://bioconductor.org/biocLite.R 下载到本地并打开,在文件开头加入如下两行命令并保存。

optionsoptions(BioC_mirror="https://mirrors.ustc.edu.cn/bioc/")
#bioconductor

options("repos" = c(CRAN="https://mirrors.tuna.tsinghua.edu.cn/CRAN/",
    CRANextra = "http://www.stats.ox.ac.uk/pub/RWin"))
#cran

然后使用 source调用本地biocLite.R文件安装bioclnstaller,再进行安装

source(/your/path/biocLite.R)
BiocInstaller::biocLite()

第四步:Windows 的中文坑

Windows配置文件Rconsole,通过R代码查找路径:file.path(R.home('etc'), 'Rconsole'),把文件里的languange改为en language = en

第五步: Windows 的 Unicode 坑

windows安装EBSeq 会发现一个神奇的报错

unexpected INCOMPLETE_STRING

修方式参考 https://github.com/rstudio/shiny/pull/968

依次输入命令

Sys.setlocale(,'English')
"\u2264"
iconv("\u2264", "UTF-8")

第六步:给自己一个 Rlib 权限

在windows里经常会看到关于权限的报错或者警告,可以通过设置给自己一个权限。

打开R的安装文件夹,右击鼠标选择属性然后选择安全设置,给Users添加三个之前没有的权限。

image

针对Linux系统

针对linux服务器,R的升级需要你首先得有Linux sudo 权限。根据谢神的忍者指南,R 的本身升级只需要下面几个命令。

sudo apt-add-repository -y "deb http://cran.rstudio.com/bin/linux/ubuntu`lsb_release -cs`/"sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E084DAB9
sudo apt-get update
sudo apt-get install r-base-dev
sudo apt-get build-dep r-base-dev

升级 R 之后依旧最好是设置 Renviron 和 Rprofile,需要更改为国内的两个镜像。

在对R包进行升级的时候,有时候会提示部分R 包无法升级,是因为所在的path你本身没有权限修改,比如"/usr/local/lib/R/site-library"。这个时候可能就需要通过sudo R --vanilla登陆,然后把你没有权限的包先卸载掉,然后再正常登陆安装到自己有权限的默认路径里去。

相关文章

网友评论

      本文标题:R安装升级后的若干规定动作

      本文链接:https://www.haomeiwen.com/subject/caupiftx.html