2  Installing R

Important Note Regarding Chromebooks

If you have a Chromebook rather than a Windows or Mac computer, these installation instructions will not work. While there are ways to install R, RStudio, and other software on Chromebooks the process for doing so is different depending on what version of ChromeOS you have and may not be supported on older models. If this problem applies to you, please make an appointment or come by during office hours as soon as possible so we can figure out what the appropriate steps to get everything up and running are.

The easiest way to install R is to go to this website and select the operating system you use.

For Mac users it is important to select the correct download for your chip. If you are unsure click on the Apple logo in the top left of your screen and then click about this Mac.

Look out for what chip your machine uses

I would download the one that says arm64. If your chip says “intel something or other” then you would click on the one that says Intel Macs.

XQuartz for MacOS Users

If you downloaded either of the MacOS versions above, you also need to download and install XQuartz. This step is only for MacOS users.

For Windows please click on this link and then follow this link and download the appropriate version of the software for your operating system. To check whether you need the X64 version or the X86 version press the windows + x keys and then click on system. You are looking for something that looks like this

Then choose 64 or 86.

2.1 R Tools and XCode

Occasionally some of the packages we will use may not be available for your version of R. This is not a problem since many package writers have the code online and we need to download them. This does require we have some additional things on our computer.

Required Step

For some of the packages we will need we may need to have some additional things installed in order for it to work.

If you are on a Windows operating system, you will need to install Rtools 4.3 which can download by clicking on the hyperlink below. Rtools is required to install packages from source and, more importantly, anything that requires a C++ compiler.

Once again, during the installation process you can just leave things at their default settings, especially in the case of the installation directory since changing its default locations may result in errors during package compilation. After you have completed this step, you will need to install the required packages by running the code below in order to successfully render the Quarto document for problem set 0. If you encounter errors when rendering the document, please ensure you have these packages installed.

Required Step

For some of the packages we will need we may need to have some additional things installed in order for it to work. This is a required step for much of the code we will use throughout this course.

If you are on a MacOS operating system, you will need to install the Xcode developer tools. You can obtain the full MacOS development environment from the Apple AppStore using the link below. Xcode is required to install packages from source and, more importantly, anything that requires a C++ compiler, including though not limited to Stan.

However, since downloading this can be extremely time consuming given the large size of the full development tools suite an alternative option is to install a paired down version that provides the tools necessary for our purposes in this course without the overhead of the full Xcode development environment. You can install the paired down version of Xcode by running the code below in the RStudio console. Just copy and paste and hit enter.

## MacOS Users may need to install the rstudioapi manually first
install.packages("rstudioapi")

## Run the command to install xcode-select
rstudioapi::terminalExecute(
  command = "xcode-select --install"
)

2.2 Installing Rstudio

So now that we have installed R we should install Rstudio. Rstudio is simply a way to interact with R that is a lot more user friendly. You can google RStudio Desktop Download or you can simple click on this hyperlink and it will take you to the download page. Again just install the version of Rstudio that works with your operating system.