A brief installation guide for R and RStudio
Download and install R
The official website of R is https://www.r-project.org/. You can visit the website and find a CRAN (Comprehensive R Archive Network) mirror site, or choose one of the followings, to download the appropriate program for your operating system, and follow the guidance from the website to install. The current stable version is R 3.4.1 (Sep 18, 2017). Note that all the mirror sites are exactly the same, so you only need to visit one of them.
- TUNA Team, Tsinghua University: https://mirrors.tuna.tsinghua.edu.cn/CRAN/
- University of Science and Technology of China: https://mirrors.ustc.edu.cn/CRAN/
- Lanzhou University Open Source Society: https://mirror.lzu.edu.cn/CRAN/
For example, if you are using a Windows system, you can
- Click “Download R for Windows” on the front page of any mirror site
- Click “base” or “install R for the first time”
- Click “Download R 3.x.x for Windows”
Now you can use R! However, in order to make the world easier, I strongly recommend you to also install the RStudio.
Download and install RStudio
RStudio is a popular IDE (Integrated Development Environment) widely used for R programming. It will greatly improve your working efficiency with R. You should install it after the base R program being installed. The official website of RStudio is https://www.rstudio.com/.
You can visit
and choose the Desktop version. The current version is RStudio Desktop 1.0.153 (Sep 18, 2017). If you are using Windows, you can click the “RStudio 1.x.x - Windows Vista/7/8/10” at the bottom of the page to download the installer and install the program.
A great feature of R is that there are many packages provided by the development community and users. However, most of them are not included in the base R program, meaning that you have to install them manually. Here I introduce how to install the package “AER” through RStudio.
- Open RStudio, select Tools > Global Options… > Packages.
- Choose a mirror at CRAN mirror (click Change…, and choose e.g. “China (Beijing) [https] - TUNA Team, Tsinghua University”).
- Click Apply and then click OK.
- Select Tools > Install Packages…, type “AER” below Packages (separated multiple with space or comma), check Install dependencies, and then click Install.
- If RStudio returns no errors, you have successfully installed the package “AER” and other packages it relies on.