Table of contents

Apple Command Line Tools

Apple provides a suite of “command line tools” to facilitate computer programming, and these tools include git which we will use for this workshop. To install the command line tools, you will need to open the Terminal application. You can find the Terminal app with a few different approaches:

  • Search for “Terminal” in Spotlight:

    Search for Terminal in Mac Spotlight

  • From Finder, navigate to the “Applications” folder, then the “Utilities” folder, and open Terminal from there:

    Open Terminal from Utilities

  • Use Launchpad and search for Terminal:

    Launch Launchpad

    Search for Terminal in Launchpad

A note on using Terminal: Terminal will likely (and often when you first start using it!) prompt you with messages like, “Terminal would like to access files on Desktop.” If/when you see this message, always agree! Agreeing allows your Terminal to access your computer’s file system.

When Terminal is open, type xcode-select --install into the Terminal and press Enter, which will reveal a message as follows:

xcode-select --install

Alternatively, if you see the following message, this means you have previously installed command line tools and are all set with this section!

xcode-select --install has previously been run

Shortly after, a separate window will pop up prompting you to install command line tools, where you should click Install:

xcode-select --install popup

A license agreement will then appear, which you should Agree to in order to continue with the installation. Finally, command line tools will install, and you can follow its progress in this window that will appear. This screen tends to first appear with outrageous installation times, like 165 hours (!) below. Don’t panic! These outrageous times will drop quickly, and the whole process will really take about 10-20 minutes.

xcode-select --install installing

R and RStudio

This workshop does not require a specific R or RStudio version. If you already have R and RStudio installed, you can skip this section!

Installing R

First, navigate to the CRAN website in the browser: https://cran.r-project.org/. Click the link Download R for macOS:

CRAN Landing Page

On the next page, click the link to install either R-4.3.1-arm64.pkg for M1/M2 Macs, or R-4.3.1-x86_64.pkg for Intel Macs.

Website with link to download R

Open the downloaded R installer, and follow instructions to install R onto your computer. Make sure to agree to the license in the setup menu and give your computer’s password when prompted!

An alternative installation approach

Instead of manually downloading R, we in the Data Lab have enjoyed using the command-line software rig to manage different versions of R. If you are comfortable with command-line software, you are welcome to install rig and use it to install your preferred R version.

Installing the RStudio IDE

First, navigate to the RStudio website’s Download page in the browser: https://posit.co/download/rstudio-desktop/#download. Click the large link to Download RStudio for Mac:

RStudio Download Page

Open the downloaded RStudio installer, and follow instructions to install it onto your computer. Once the installation process is completed, you can now safely delete (eject) the disk image file.

Installing necessary R packages

For this workshop, you will need to have the following R packages installed:

  • here
  • optparse
  • renv
  • rmarkdown
  • tidyverse

If you already have these packages installed, you’re good to go!

Otherwise, open RStudio (this assumes both R and RStudio have been installed). You can check if these packages are installed by scrolling through the Packages tab in the bottom-right pane of RStudio. If you see the package of interest listed, then you know it’s installed. For example, the image below tells us that optparse is already installed and no additional action is required to install this package:

Shows that the optparse package is already installed on this computer

If you need to install any of the required packages, use the function install.packages() in Console, as follows:

# Install optparse only, for example:
install.packages("optparse")

# Install all necessary packages at once:
install.packages(c("here", "optparse", "renv", "rmarkdown", "tidyverse"))

After running this/these command(s), you will see some progress messages pass in Console (maybe in a different color from this image, but that’s ok!!). The following image shows, for example, what these messages look like for a successful installation of optparse:

Shows the process and output for installing the optparse package

Note: While installing packages, you may be prompted to install Command Line Tools if you didn’t install it already. If you see this message, agree to it and follow all installation steps for Command Line Tools.

GitKraken

We will use the GUI (graphical user interface) called GitKraken to work with git in this workshop. This GUI can be installed from https://www.gitkraken.com, where you can click “Download GitKraken Client Free” (do not pay!!):

GitKraken Landing Page

Then, select the appropriate version for your computer’s architecture.

GitKraken Download options

The GitKraken installer will now download. Double-click the downloaded disk image, and a window will appear where, as the instructions indicate, you should drag the GitKraken icon into the Applications folder icon (all within this window!).

GitKraken Drag Download

This action completes the installation, and you can now safely delete (eject) the disk image file. For more information on setting up a GitHub account and the initial GitKraken setup, see our GitHub Setup instructions.

A suitable text editor

We will use a text editor to write code as part of this workshop, (and more generally, having a good text editor is something you want anyways!). We recommend Visual Studio Code (“VS Code”), but if you already have a text editor you prefer, please feel free to stick with that! Some alternatives you may have encountered are Sublime Text and BBEdit.

⚠️ macOS comes with a “text editor” program called “TextEdit.” In spite of its compelling name, this is NOT a recommend text editor for writing computer code! Please do not use TextEdit!

Installing Visual Studio Code

If you choose to install VS Code, navigate to https://code.visualstudio.com/download in the browser.

Visual Studio Code Download Page

Click on either “Mac” link to download VS Code.

VS Code will now download as a .zip file. Depending on your browser and settings, this may decompress automatically. If it does not, open the .zip file by double clicking it, and it will decompress to the actual VS Code app called “Visual Studio Code.” You can then drag (or copy) this app file into your computer’s Applications folder to formally install it.

Visual Studio Code Installation

VS Code is a very powerful program with a ton of ways to customize it. All of the flexibility can be a tad overwhelming! There are hundreds of options that affect the program’s behavior and hundreds of available extensions which expand its functionality, or just change the way it looks. We encourage you to explore a bit on your own; we’ll be happy to share our favorite tricks during the workshop! VS Code provides some useful introductory videos as you begin your journey!

Optional: Install the VS Code command line tool

One such extension that expands VS Code’s function is a command line tool called code which you can use to open a file directly from the command line/terminal environment. (If you are unfamiliar with the command line, we will talk about it during the workshop!) To install this tool, select the View > Command Palette... menu item:

Visual Studio Code Command Palette

A little text box at the top of your window will then appear. Start to type shell in that box and you will see a menu of options pop up. Select the one that says Shell Command: Install 'code' command in the PATH to install the extension.

Visual Studio Code `code` shell command extension

You should get a message confirming a successful install, and then you will be all set!