Installing R and RStudio - Easy R Programming
可以從CRAN網(wǎng)頁(http://cran.r-project.org/)下載R并將其安裝在Windows,MAC OSX和Linux平臺上。
安裝R軟件后,還安裝可從以下網(wǎng)址獲得的RStudio軟件:http://www.rstudio.com/products/RStudio/。
1 windows安裝 R 及RStudio
1.1 安裝R
從CRAN( https://cran.r-project.org/bin/windows/base/)下載最新版本的R,雙擊您剛剛下載的文件以安裝R,不需要更改默認安裝參數(shù)

-
選擇國內(nèi)鏡像進行下載
image.png
1.2 安裝Windows Rtools
Rtools包含用于在Windows上構(gòu)建自己的軟件包或構(gòu)建R本身的工具。
在以下位置下載與您的R版本相對應的Rtools版本:https://cran.r-project.org/bin/windows/Rtools/。 將最新版本的Rtools與最新版本的R一起使用。
雙擊您剛剛下載的文件以安裝Rtools(無需更改默認安裝參數(shù))
1.3 在Windows上安裝RStudio
Rstudio主頁:https://rstudio.com/
在以下位置下載RStudio:https://www.rstudio.com/products/rstudio/download/
下載Windows版RStudio

1.4 Rstudio使用
R及Rstudio安裝完成后,可在windows開始界面找到Rstudio

我們使用R語言無需打開R,而是通過RStudio打開R。
1.5 R鏡像替換
- 以下內(nèi)容來自生信菜鳥團http://www.bio-info-trainee.com/3727.html
rm(list = ls())
options()$repos
options()$BioC_mirror
#options(BioC_mirror="https://mirrors.ustc.edu.cn/bioc/")
options(BioC_mirror="http://mirrors.tuna.tsinghua.edu.cn/bioconductor/")
options("repos" = c(CRAN="https://mirrors.tuna.tsinghua.edu.cn/CRAN/"))
options()$repos
options()$BioC_mirror
# https://bioconductor.org/packages/release/bioc/html/GEOquery.html
if (!requireNamespace("BiocManager", quietly = TRUE))
install.packages("BiocManager")
BiocManager::install("KEGG.db",ask = F,update = F)
BiocManager::install(c("GSEABase","GSVA","clusterProfiler" ),ask = F,update = F)
BiocManager::install(c("GEOquery","limma","impute" ),ask = F,update = F)
BiocManager::install(c("org.Hs.eg.db","hgu133plus2.db" ),ask = F,update = F)
# 下面代碼被我注釋了,意思是這些代碼不需要運行,因為它過時了,很多舊教程就忽略
# 在代碼前面加上 # 這個符號,代碼代碼被注釋,意思是不會被運行
# source("https://bioconductor.org/biocLite.R")
# library('BiocInstaller')
# options(BioC_mirror="https://mirrors.ustc.edu.cn/bioc/")
# BiocInstaller::biocLite("GEOquery")
# BiocInstaller::biocLite(c("limma"))
# BiocInstaller::biocLite(c("impute"))
# 但是接下來的代碼又需要運行啦
options()$repos
install.packages('WGCNA')
install.packages(c("FactoMineR", "factoextra"))
install.packages(c("ggplot2", "pheatmap","ggpubr"))
library("FactoMineR")
library("factoextra")
library(GSEABase)
library(GSVA)
library(clusterProfiler)
library(ggplot2)
library(ggpubr)
library(hgu133plus2.db)
library(limma)
library(org.Hs.eg.db)
library(pheatmap)
- 報錯解決文檔詳見:https://docs.qq.com/doc/DT2VMdmN2Y0F5SHlr
image.png
2 為Mac OSX安裝R和RStudio
從以下網(wǎng)址的CRAN下載適用于MAC OSX的R的最新版本:https://cran.r-project.org/bin/macosx/
雙擊您剛剛下載的文件以安裝R,無需更改默認安裝參數(shù))
在以下網(wǎng)址下載并安裝最新版本的RStudio for MAC:https://www.rstudio.com/products/rstudio/download/
3 在Linux上安裝R和RStudio
可以使用以下Bash腳本將R安裝在Ubuntu上:
sudo apt-get r-base
RStudio for Linux可從https://www.rstudio.com/products/rstudio/download/獲得。

