Back to Home                       

R 速查

教程

Packages

Figure 11

Figure 11

Figure 12

Figure 12

Windows 中 R 相关的安装更新

Update R

Way1: direct code way

Run the following code in “Ri”.

install.packages("installr")
library(installr)
updateR() # updating R

Running “updateR()” will detect if there is a new R version available, and if so it will download+install it (etc.). Just press “next”, “OK”, and “Yes” on everything.

Attention: during updating, you will be prompted whether need to copy the R package installed in the old version to the new version (such as Figure 1 and Figure 2), pay attention to choose according to your needs.

Figure 1

Figure 1

Figure 2

Figure 2

Way 2: update using GUI

First load installr base on the following code.

install.packages("installr")
library(installr)

After running the above code, you will see new button “installr” (Figure 3), please click it and click “Update R”. The next steps almost same as Way1.

Figure 3

Figure 3

Update R in Rstudio

After R updating, you can uninstall the old R version. Then if you next open R studio, you will see the windows like Figure 5. Just choose the “choose a special version of R”, select the newest Rversion.

If you did not uninstall the old R version.You can also open “Rstudio”, and then click “Tools-Global” Options, choose “General”. If the R version is the newest, means you complete the updating. If not, click Change, you will see figure 4, then click “choose a special version of R”, choose the newest one.

Figure 4

Figure 4

Figure 5

Figure 5

Update Rstudio

Click “Help” in “Rstudio”, and choose “Check for Update”. It will be directly linked to the official website of Rstudio, directly downloaded and installed.

Figure 6

Figure 6

In addition, you can also check your R version by the following code.

# Check version R
version

Update R packages in Rstudio

Open Rstudio, in “Tool”, choose “Check for Package Updates”. If you get figure 7, means all your packages are newest version.

Figure 7

Figure 7

Figure 8

Figure 8

Otherwise, you can also use code to update all your R packages in Rstudio.

# check packages
old.packages()
# update all the packages
update.packages()

Install Rtools

https://cran.r-project.org/bin/windows/Rtools/

下载完成后一路点击 Next 安装即可;随后,需要将 R 和 Rtools 添加到 windows 系统环境变量中:打开“此电脑”,在空白处右击,依次在窗口点“属性”——“高级系统设置”——“高级”——“环境变量”,在“系统变量”中寻找 Path,需要在 Path 内添加 R 的 bin 目录路径,rtools 的目录,以及 rtools 的 usr/bin 目录。

Figure 9

Figure 9

添加完环境变量后,就可以在 cmd 命令行下就可以打开 R。

Figure 10

Figure 10

Reference


Back to Home