安装R
1.下载安装R
# /home/ihou/R下载安装R4.0.3
wget http://mirrors.ustc.edu.cn/CRAN/src/base/R-4/R-4.0.3.tar.gz
tar -zxvf R-4.0.3.tar.gz
cd R-4.0.3
./configure --prefix=/home/ihou/R
make
make install
2.配置环境(当前)
vi .bash_profile
# 按"i"可编辑,“ESC”键停止编辑,":wq"退出
export PATH="$PATH:/home/ihou/R/bin"
source .bash_profile
在 linux中设置环境变量一般使用bash_profile进行配置
其中/etc/bash_profile 表示系统整体设置 ,生效后系统内所有用户可用
而 ~/.bash_profile 只表示当前用户的个人设置,生效后只该用户可用。
3.配置环境(全局)
# R环境配置
vim /etc/profile
R_HOME=/usr/local/R
PATH=$PATH:$R_HOME/bin
source /etc/profile
4. 命令
# 查看R版本
R --version
# 查看R包路径(进入R环境)
> .libPaths()
5.安装R工具包
# tidyverse镜像安装
install.packages ("tidyverse",repos="https://mirrors.tuna.tsinghua.edu.cn/CRAN/")
# git安装
devtools::install_github('chris-mcginnis-ucsf/DoubletFinder')
上述安装不了可以用下面这种
# 如果R版本为3.6版本,请将版本号设置为version = "3.11"
# version = "3.12"适用于R 4.0.0
if (!requireNamespace("BiocManager", quietly = TRUE))
install.packages("BiocManager")
BiocManager::install(version = "3.12")
library("BiocManager")
# 普通安装
BiocManager::install("ggplot2")
#一次安装多个包
BiocManager::install(c("ggplot2","ggtree","DESeq2"))
#安装特定的包
source("https://bioconductor.org/biocLite.R")
BiocInstaller::biocLite(c("GenomicFeatures", "AnnotationDbi"))