Article Directory
foreword
I don’t produce knowledge, I’m just a porter of knowledge. The following content is from Bilibili - Xuzhou Geng’s installation tutorial: probably the best R language installation guide 哔哩哔哩bilibili
Personally, I think the installation of R is more troublesome, so I modified the installation video he talked about and wrote it in the form of a document, so that I or others can refer to it in the future
1. What is the R language?
The R language is a language and operating environment for statistical analysis and graphics. R is a free, free, open-source software belonging to the GNU system. It is an excellent tool for statistical computing and statistical graphics.
2. R download
1. Official website
Official website: https://www.r-project.org/
Enter the official website, which is like this
R is a free software environment for statistical computing and graphics. It compiles and runs on a wide variety of UNIX platforms, Windows and MacOS. To download R, please choose your preferred CRAN mirror.
clickdownload R
You will enter this page, you can see a lot of mirror images
If you are in China, choose the Chinese mirror, so that the download will be faster
you can just choose the first oneTsinghua University Open Sourcemirror image of
What is a mirror, and why choose a Chinese mirror?
Mirroring is a form of file storage and a type of redundancy. The data on one disk has an identical copy on another disk, which is a mirror.
This is the explanation on Baidu, and it seems rather difficult to understand. To put it simply, it is: for example, there is a cheese factory in the United States, and then a cheese factory is also built in China. The cheese produced in these two countries is the same, so it can be considered These two cheese factories are mirror images of each other. If you want to eat cheese, will you go to the United States to buy cheese or go to China to buy cheese? That must be China, because it is close, and it is fast, which is why we choose the mirror image of China.
After selecting the mirror image and entering it, it looks like this. You can see that there are download and installation packages for three operating systems here.
You are using the system on which to download the installation package corresponding to that system
I am here to use it under windows, so I choose Download for Windows
(it is recommended to use R under windows)
Click to see this page, and then click base
and Rtools
to jump into R's 基本
and 工具
download pages respectively
2. download base
Click base
to enter like this
If you want to download the latest version of R, you can directly click the download address at the top
To download historical versions of R, click here Previous releases
to select the version you want
For example, I choose the first version of R 4.1.2 and click to enter
select this .exe
download
save document
3. download Rtools
Click Rtools
to enter like this
Click Older editions
to view all versions
The Rtools version you want to download should be the same as the base version you downloaded earlier
For example, the version I downloaded from base before is4.1.2, then Rtools should choosertools40-x86_64.exeto download
then save
The download of R and RTools is complete
3. Rstudio download
1. Official website
Official website: https://www.rstudio.com
2. download Rstudio
You can click DOWNLOAD FREE DESKTOP IDE
to enter the download page
chooseRStudio Desktop - FreeunderDOWNLOAD
Jump here, click 下载
, both places are fine
保存
I created a new folder on the D drive to save the three executable files I downloaded before.
Below I also provide three executable files related to R installation that I downloaded.
百度网盘下载链接
Link: Network disk link
Extraction code: ikya
Subsequent installations are basically fool-proof installations
Four, R installation
Double-click the previously downloaded executable fileR-X.X.X-xxx.exe
Select the language used for installation,确定
下一步
Choose a non-Chinese installation path, it is not recommended to have spaces in the path (if you install it in a Chinese path, there may be problems), I will download it directly to the C drive, because my C drive is quite large now,下一步
Remove unnecessary things (my computer is 64-bit, and then I don't need translation),下一步
accept default options下一步
下一步
下一步
Start the download
and the installation is complete, click结束
Five, Rtools installation
Double-click the previously downloaded executable fileRtools-XXXXX.exe
next
clicknext
clickInstall
start download…
The installation is complete, clickFinish
6. Rstudio installation
Double-click the previously downloaded executable fileRStudio-XXXXX.exe
click下一步
The same installation directory should not be under the Chinese path
click安装
installing…
The installation is complete, click完成
Seven, java environment configuration
Why configure java environment variables?
Some packages in R depend on java, and some commands cannot be used without configuration
You can view this link for configuration: java environment configuration (detailed tutorial)
8. Run RStudio
If it can be opened, it means that the R language and RStudio are installed successfully.
In Tools
the Global Options
can set some global properties, such as font, size, etc...
You can simply try to draw a picture
plot(x=1,y=1)
10. R package installation strategy
1. Configure mirroring
1. Modify the configuration file
Find the file that Rprofile.site
configures (I installed it by default, and you can usually find the configuration file under the Program Files folder of the C drive), open it in Notepad, and paste the following configuration
## 设置镜像
local({
r <- getOption("repos")
r["CRAN"] <- "https://mirrors.tuna.tsinghua.edu.cn/CRAN/"
options(repos=r)}
)
options(BioC_mirror="https://mirrors.ustc.edu.cn/bioc/")
## 设置下载方式
options("download.file.method"="libcurl")
options("url.method"="libcurl")
If you can't save it when you save it, you may wish to copy this file to your desktop first, and replace the file in the etc directory after you modify it on your desktop.
Check whether the mirroring is configured successfully
input the command
getOption("repos")
getOption("BioC_mirror")
Appearing this means that the mirror configuration is successful
1. Modify global settings
at Tools
theGlobal Options
Choose a mirror image of China
2. Simple commands
命令 + enter ==> 执行
See where R packages are installed
.libPaths()
View installed R packages
installed.packages()
View installable R packages
available.packages()
Check if a package exists
library(包名)
例如:library(xlsx)
Install local R packages
install.packages("输入你文件的地址",repos = NULL)
例如:
install.packages("~/../Desktop/GO.db_3.7.0.tar.gz",repos = NULL)
View documentation
?install.packages
Uninstall the R package
remove.packages("R包名")
例如:
remove.packages("xlsx")
3. Upgrade the R package
The following are the packages that are often used, copy the following command and press Enter to execute it.
update.packages()
if(!require("xlsx")) install.packages("xlsx")
if(!require("tidyr")) install.packages("tidyr")
if(!require("dplyr")) install.packages("dplyr")
if(!require("ggplot2")) install.packages("ggplot2")
if(!require("data.table")) install.packages("data.table")
if(!require("ggrepel")) install.packages("ggrepel")
if(!require("devtools")) install.packages("devtools")
if(!require("BiocManager")) install.packages("BiocManager")
It may take some time,
the downloaded package will go to this directory
4. Install the R package on Bioconductor
Copy the following command and press Enter to execute it
BiocManager::install()
if(!require("DESeq2")) BiocManager::install("DESeq2")
if(!require("clusterProfiler")) BiocManager::install("clusterProfiler")
Summarize
Thanks to the big guy for sharing, I was able to install R on my computer with difficulty, and make a record of this. In case I need to download R in the future, I don’t need to spend time watching the video. I will also share some notes on my learning R language in the future. .