1.2 Installing On Mac/Apple Machines

These instructions are intended for use on personal machines running the Apple/Mac OS. While these instructions have been used to install the R toolchain on several machines, each of the steps may not be applicable for every version of the OS. We welcome input on ways to improve these instructions so that they are more widely applicable. Therefore, if any errors are discovered in these instructions, please open an issue detailing the problem.

1.2.1 Install The R Environment

  1. Go to https://cloud.r-project.org/ and download latest version of R

  2. During the installation process, accept all of the defaults

  3. Once the install is complete, open R - your installation should look similar to the image below. Admittedly it’s not very exciting to look at, we’ll fix that soon

  1. At the command prompt type .libPaths()

    1. This function returns the directory(ies) where R can store your downloaded packages

    2. As you’re installing R for the first time, there may be only one directory listed now - as you use R, the number of directories is likely to increase

    3. The order of the directories indicates the order R will use in trying to store the package

  2. Now type names(installed.packages()[,1])

    • This returns a list of the packages that installs with the R environment

    • These packages are stored in the first directory returned by .libPaths()

1.2.2 Install R Packages

The real power of R is experienced by using AND creating packages. Packages ‘add-on’ to the power of R in the same way that apps add to your smartphone (For most cases, there’s an app a package for that!). Creating packages allows researchers to quickly share their work with the world. Using packages allows researchers to incorporate cutting-edge capabilities, as soon as they’re developed.

There are also several ‘stores’ or repositories from which packages can be installed.

  • The Comprehensive R Archive Network (CRAN) - the official repository for R packages

  • GitHub - many packages are stored here prior to being accepted for publication to the CRAN

  • Bioconductor - a repository of bioinformatics-related R packages

  • The Microsoft R Archive Network (MRAN)

  1. Let’s install a package to make sure everything is working

  2. Run install.packages('data.table') to install the data.table package from the CRAN

  3. If this is your first package, you may be asked to choose a ‘CRAN mirror’ - select 0 - Cloud

  4. You may also be asked if you’d like to create a personal library - if so, select Yes and accept the default folder location

  5. At this point the data.table package should download as shown in the GIF below

  1. If the package failed to download, skip ahead to Install RStudio and try to install the data.table package after RStudio is installed

  2. In addition to the data.table package there are several packages every R user needs

  3. To install these packages paste the following lines into the console

    1. install.packages(c('devtools','rmarkdown'))

    2. install.packages(c('DT','knitcitations','RefManageR'))

    3. install.packages(c('shiny','RJSONIO','xtable'))

  4. If these packages (and their dependencies) install - move on to Install RStudio

1.2.3 Install RStudio

RStudio is, by far, the most popular integrated development environment (IDE) for the R programming language. Other popular IDE’s that can be used with R include: Emacs, Microsoft R Open, Notepad++, Eclipse, and Knime. RStudio installs with several open-source applications and provides syntax highlighting, code completion suggestions, and diagnostics for the following languages:

  • R (*.R)

  • Matlab (*.m)

  • Python (*.py)

  • Julia (*.julia)

  • C++ (*.cpp)

  • JavaScript (*.js)


  • JSON (*.json)

  • CSS3 (*.css)

  • HTML5 (*.html)

  • YAML (*.yml)

  • Markdown (*.md)

  • Coffee (*.coffee)

  1. RStudio can be installed by going HERE and selecting the version for your system.

  2. Once installed, open RStudio to ensure it’s linked with the your installed version of R

    1. If your R installation is found, RStudio will open - no news is good news

    2. If your R installation is not found, RStudio will fail to open

      • If this happens, close RStudio and try re-installing R

      • Once R has been successfully re-installed try to open RStudio again

  3. The completed RStudio installation should look similar to the image below

1.2.4 Install LaTeX

  1. MacTeX can be installed from HERE

    1. Note: Choose the option to Install Packages on the Fly

    2. Otherwise accept all the defaults

  2. Once MacTeX has finished installing, ensure it’s configured correctly by following the steps below

    1. Select ‘File’ > ‘New File’ > ‘R Markdown’ to create a new R Markdown file

    2. In the ‘Document’ dialog choose ‘PDF Document’

    3. Once the demo file opens, click knit to knit the rmarkdown file into a PDF document

    4. You’ll be asked to give the new file a name, choose something simple, like ‘test’

    5. Note: The first time you knit an rmarkdown document knits into a PDF it can take a moment to compile as several LaTeX packages may need to be installed in the background.

  3. If a pop-up window appears, asking permission to install a \(\LaTeX\) package, check the default location of the package repository and allow the package to install

1.2.5 Create a GitHub Account

  1. Go to GitHub.com and sign up for an account

    1. Choose a username

    2. Add an email address

    3. Enter a password

  2. After logging in, search for Auburngrads/test-repo to find the test-repo repository created by Auburngrads

  3. On the test-repo page click to fork a copy of the repo to your account

1.2.6 Install & Configure Git

  1. Git can be downloaded and installed from HERE

  2. Once the install completes, close and re-open RStudio

    1. Open the ‘Tools’ menu and select ‘Global Options’

    2. In ‘Global Options’ select ‘Git/SVN’

    3. If the path usr/bin/git is already listed in the ‘Git Executable’ window, Git has been installed correctly

    4. If the ‘Git Executable’ window is blank click ‘Browse’ then press Command + Shift + . to view the hidden folders visible and then navigate to usr/bin/git click OK

  3. Next, we’ll make sure Git is configured

    1. Open the Terminal application and type the following two lines

    2. git config --global user.name your.github.username

    3. git config --global user.email your.github.email

    4. Close the Terminal

  4. Finally, let’s set up the SSH connection between RStudio and GitHub

    1. In RStudio, open ‘Tools’ \(\rightarrow\) ‘Global Options’ \(\rightarrow\) ‘Git/SVN’

    2. Toward the bottom of the ‘Git/SVN’ dialog click ‘Create RSA Key’

    3. After the RSA Key appears click ‘Close’

    4. Click ‘View Public Key’ and copy the text in the window

    5. Return to your GitHub account page and click the drop-down arrow next to your account avatar (upper-right corner) \(\rightarrow\) select ‘Settings’

    6. Under ‘Settings’ select ‘SSH and GPG Keys’

    7. Select ‘New SSH Key’ \(\rightarrow\) choose a name for the key, like personal machine

    8. Paste the public key in the window and select ‘Add SSH Key’