To get started, you will need to download both R and RStudio. These are separate programs. Follow the instructions below to install R and RStudio and set a few default options.
R can be downloaded from one of the “CRAN” (Comprehensive R Archive Network) sites. In the US, the main site is at http://cran.us.r-project.org/. Look in the “Download and Install R” box at the top of the page. Click on the appropriate link based on your operating system.
If you already have R on your computer, make sure you have the most updated version.
On the “R for macOS” page, there are multiple software releases that could be downloaded. If you are running Big Sur or higher, click on the R-4.5.2-arm64.pkg to download the latest release; if you are running an earlier operating system, download the appropriate version listed under “Binary for legacy macOS/OS X systems.”
After the package finishes downloading, locate the installer on your hard drive, double-click on the installer package, and follow the installation instructions. If requested, select a destination for the installation of the R framework (the program) and the R.app GUI. Note that you will need to supply the Administrator’s password (i.e., your computer password) to complete the installation. Close the window when the installation is done. Once complete the installer can be moved to the trash.
You should now see R in your list of applications.
Next, navigate to the XQuartz download page. Click on the most recent version of XQuartz to download the application.
Run the XQuartz installer and follow the instructions to install the software. XQuartz is needed to create windows to display many types of R graphics (this used to be included in macOS until version 10.8 but now must be downloaded separately). Once complete the installer can be moved to the trash.
On the “R for Windows” page, click on the “base” link, which should take you to the “R-4.5.2 for Windows” page.
On this page, click “Download R 4.5.2 for Windows”, and save the exe file to your hard disk when prompted. Saving to the desktop is fine.
To begin the installation, double-click on the downloaded file. Don’t be alarmed if you get unknown publisher type warnings. Window’s User Account Control will also worry about an unidentified program wanting access to your computer. Click on “Run”.
Select the proposed options in each part of the install dialog. When the “Select Components” screen appears, just accept the standard choices
Note: Depending on the age of your computer and version of Windows, you may be running either a “32-bit” or “64-bit” version of the Windows operating system. If you have the 64-bit version (most likely), R will install the appropriate version and will also (for backwards compatibility) install the 32-bit version. You can run either, but you will probably just want to run the 64-bit version.
To download and install RStudio, follow the directions below:
Once you have successfully installed both R and RStudio, open RStudio to set a couple of default options.
Note that RStudio is the only application you will need to open in order to complete work for this course. It is necessary to have R installed to use the programming language; however, we will not actually ever open R itself. We will only open and work in the RStudio application.
While not required, I strongly suggest that you change preferences in RStudio to never save the workspace. This means that whenever you open RStudio, your will always open with a clean environment (we’ll talk more later about what that means). See Ch. 8.1 of R4DS for some more background. Follow these instructions to change this default setting:
You only need to set these preferences once.
Next, to avoid a crowded workspace, you will want to display the output of your code only in the Console and Plots windows rather than “inline” in the Editor window. (An explanation of these different windows is provided on the Assignment Guidelines page, so don’t worry if this explanation doesn’t make much sense at the moment.)
Now that you’ve installed R and RStudio, move on to the Assignment Guidelines page to get familiar with expectations for assignments in this course and learn some basics of working in RStudio. I encourage you to have RStudio open as you review the Assignment Guidelines so that you can follow along and try things out yourself as you read.
If you have any questions, please don’t hesitate to reach out to me.
Jenny Wagner, PhD, MPH
Assistant Professor
Department of Public Health
California State
University, Sacramento
jenny.wagner@csus.edu