R.002 安裝R及Rstudio

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ù)

image.png

  • 選擇國內(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

image.png

1.4 Rstudio使用

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


image.png
我們使用R語言無需打開R,而是通過RStudio打開R。

1.5 R鏡像替換

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)

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/獲得。

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。

友情鏈接更多精彩內(nèi)容