本文介绍一下从零搭建R环境。
那么R语言,RTools和Rstudio有什么区别?
R是基本的编程语言,单纯使用R是可以的,如图:

为了编写R程序,单独的R语言肯定不够,因为需要对数据、文档、函数的批量管理,这个时候需要Rstudio。(我这里是VScode)

这个时候,我们可以查看变量、绘图、管理项目。可能有些东西不满足,比如下载GitHub的包等等,这个时候,你就要安装Rtool。
R语言安装
首先安装R,点击Windows
https://cran.r-project.org/index.html
推荐选择镜像:
https://mirrors.tuna.tsinghua.edu.cn/CRAN/

再点击base:

点击Download R-4.2.3 for Windows,下载最新版4.2.3。
或点击Previous,下载一个之前的稳定版本,如4.1.2

下载完安装包一路点到底,安装即可。
Rstudio
https://posit.co/products/open-source/rstudio/
点击右上角的Download,再点击Download Rstudio

之前我们已经安装好R了,因此直接下载Rstudio安装

下载好双击exe运行到底就行了。
Rtools
Rtools安装包有130M,且安装文件有1G,正常安装包括镜像安装都会很慢,这时候需要使用一些工具:
NDM下载器:https://www.neatdownloadmanager.com/index.php/en/
Rtools下载地址:https://cran.r-project.org/bin/windows/Rtools/
我选择的是最新版Rtools40,64位32位兼容版本,这个可以根据自己情况合理选择

将下面的Rtools下载地址复制到NDM的url栏里,即可下载
https://cran.r-project.org/bin/windows/Rtools/rtools40-x86_64.exe

下载好了直接安装rtool,双击即可
安装好了打开R

输入:
writeLines('PATH="${RTOOLS40_HOME}\usr\bin;${PATH}"', con = "~/.Renviron")
- 1
再输入:
Sys.which("make")
- 1
若输出R路径则成功

本文由 mdnice 多平台发布