2  Install R & RStudio

Learning Objectives: After this chapter you will be able to:

  • Install R on Windows, macOS, or Linux from a CRAN mirror.
  • Verify an installation by running R.version.string.
  • Install RStudio Desktop after installing R.
  • Create an RStudio Project to keep the working directory, history, and settings together in a single .Rproj file.

2.1 R

Follow these steps:

  • Download R for your operating system from a CRAN mirror (Windows, macOS, or Linux installers are listed there).
  • Run the installer with default options.
  • Verify the installation by opening R (or RStudio) and typing R.version.string in the Console.

2.2 RStudio

Follow these steps:

  • Download RStudio Desktop from posit.co/download/rstudio-desktop.
  • Install it after installing R (RStudio needs R to work).
  • Open RStudio and create a new project via File > New Project (this creates an .Rproj file that keeps your working directory, history, and settings together).
  • Verify your setup by running R.version.string in the R console.

Key points

  • Install R from a CRAN mirror before installing RStudio Desktop.
  • Type R.version.string in the R or RStudio Console to verify the installation.
  • Create an RStudio Project to keep the working directory and settings together.

Next: Variables in R