Installation Guide for R, Rstudio, and Rtools

Author
Affiliation

Prof. J Babiera and Prof. R Cuenca

Center for Computational Analytics and Modelling (CCAM), PRISM, MSU-IIT

For Windows

To install R, RStudio, and Rtools on a 64-bit Windows system, follow these steps:

1. Install R

  • Visit the Comprehensive R Archive Network (CRAN) at https://cran.r-project.org.

  • Click on “Download R for Windows.”

  • Select “base,” then click on the link to download the latest R version for Windows.

  • Run the downloaded .exe file.

  • Follow the installation prompts, accepting default settings.

    (A more visual take on the installation prompts that typically pop-up is provided in the following YouTube tutorial:

2. Install RStudio

  • Go to the RStudio website: https://posit.co/download/rstudio-desktop/.

  • Scroll down and click on “Download RStudio Desktop for Windows.”

  • Run the downloaded installer.

  • Follow the installation prompts, accepting default settings.

    For a visual way to setup RStudio, follow this YouTube tutorial:

3. Install Rtools

Note: Rtools is necessary for building R packages from source that require compilation.

  • Visit the Rtools page on CRAN: https://cran.r-project.org/bin/windows/Rtools/.

  • Choose the version of Rtools that matches your R version:

    • For R 4.2.x, select Rtools42.

    • For R 4.3.x, select Rtools43.

    • For R 4.4.x, select Rtools44.

  • Download the corresponding Rtools installer.

  • Run the downloaded installer.

  • Follow the installation prompts, accepting default settings.

4. Verify Rtools Installation

  • Open RStudio and go to the Console Pane.

  • Install the pkgbuild package if not already installed:

    install.packages("pkgbuild")
  • Load the pkgbuild package:

    library(pkgbuild)
  • Check if Rtools is correctly installed:

    has_rtools(debug = TRUE)

    If Rtools is properly installed, this function will return TRUE.

For macOS

To install R and RStudio on a macOS system, follow these steps:

1. Determine Your Mac’s Processor Type

  • Click the Apple menu in the top-left corner and select “About This Mac.”

  • Review the information displayed:

    • If it mentions “Intel,” you have an Intel-based Mac.

    • If it mentions “Apple M1,” “Apple M2,” or similar, you have an Apple Silicon-based Mac.

2. Install R

  • Visit the Comprehensive R Archive Network (CRAN) at https://cran.r-project.org.

  • Click on “Download R for macOS.”

  • Choose the appropriate installer based on your processor type:

    • For Intel-based Macs: Download the R-x.x.x-x86_64.pkg file.

    • For Apple Silicon-based Macs: Download the R-x.x.x-arm64.pkg file.

  • Open the downloaded .pkg file and follow the on-screen instructions to complete the installation.

3. Install RStudio

  • Go to the RStudio download page at https://posit.co/download/rstudio-desktop/.

  • Click on “Download RStudio Desktop for macOS.”

  • Open the downloaded .dmg file.

  • Drag the RStudio icon into the Applications folder.

4. Launch RStudio

  • Navigate to the Applications folder.

  • Double-click the RStudio icon to open the application.

5. Install Xcode Command Line Tools (If Necessary)

Some R packages require additional tools to compile. If you encounter errors during package installation, you may need to install Xcode Command Line Tools:

  • Open Terminal.

  • Type the following command and press Enter:

    xcode-select --install
  • Follow the on-screen instructions to complete the installation.

Additional Tips:

  • Regularly check for updates to R and RStudio to ensure compatibility with the latest macOS versions.

  • If you encounter issues with package installations, ensure that your system has the necessary tools and dependencies installed.

Note

There’s no need to install Rtools in macOS.

By following these steps, you can set up a robust R and RStudio environment on your Mac, tailored to its specific hardware and software configurations.

What’s Next?