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
Go to https://cloud.r-project.org/ and download latest version of R
During the installation process, accept all of the defaults
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

At the command prompt type
.libPaths()
This function returns the directory(ies) where R can store your downloaded packages
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
The order of the directories indicates the order R will use in trying to store the package
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)
Let’s install a package to make sure everything is working
Run
install.packages('data.table')
to install thedata.table
package from the CRANIf this is your first package, you may be asked to choose a ‘CRAN mirror’ - select
0 - Cloud
You may also be asked if you’d like to create a personal library - if so, select
Yes
and accept the default folder locationAt this point the
data.table
package should download as shown in the GIF below
If the package failed to download, skip ahead to Install RStudio and try to install the
data.table
package after RStudio is installedIn addition to the
data.table
package there are several packages every R user needsTo install these packages paste the following lines into the console
install.packages(c('devtools','rmarkdown'))
install.packages(c('DT','knitcitations','RefManageR'))
install.packages(c('shiny','RJSONIO','xtable'))
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
R (*.R)
Matlab (*.m)
Python (*.py)
Julia (*.julia)
C++ (*.cpp)
JavaScript (*.js)
JSON (*.json)
CSS3 (*.css)
HTML5 (*.html)
YAML (*.yml)
Markdown (*.md)
Coffee (*.coffee)
RStudio can be installed by going HERE and selecting the version for your system.
Once installed, open RStudio to ensure it’s linked with the your installed version of R
If your R installation is found, RStudio will open - no news is good news
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
The completed RStudio installation should look similar to the image below

1.2.4 Install LaTeX
MacTeX can be installed from HERE
Note: Choose the option to
Install Packages on the Fly
Otherwise accept all the defaults
Once MacTeX has finished installing, ensure it’s configured correctly by following the steps below
Select ‘File’ > ‘New File’ > ‘R Markdown’ to create a new R Markdown file
In the ‘Document’ dialog choose ‘PDF Document’
Once the demo file opens, click
knit
to knit the rmarkdown file into a PDF documentYou’ll be asked to give the new file a name, choose something simple, like ‘test’
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.
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
Go to GitHub.com and sign up for an account
Choose a username
Add an email address
Enter a password
After logging in, search for
Auburngrads/test-repo
to find thetest-repo
repository created byAuburngrads
On the
test-repo
page clickto fork a copy of the repo to your account
1.2.6 Install & Configure Git
Git can be downloaded and installed from HERE
Once the install completes, close and re-open RStudio
Open the ‘Tools’ menu and select ‘Global Options’
In ‘Global Options’ select ‘Git/SVN’
If the path
usr/bin/git
is already listed in the ‘Git Executable’ window, Git has been installed correctlyIf the ‘Git Executable’ window is blank click ‘Browse’ then press
Command + Shift + .
to view the hidden folders visible and then navigate tousr/bin/git
click OK
Next, we’ll make sure Git is configured
Open the Terminal application and type the following two lines
git config --global user.name your.github.username
git config --global user.email your.github.email
Close the Terminal
Finally, let’s set up the SSH connection between RStudio and GitHub
In RStudio, open ‘Tools’ \(\rightarrow\) ‘Global Options’ \(\rightarrow\) ‘Git/SVN’
Toward the bottom of the ‘Git/SVN’ dialog click ‘Create RSA Key’
After the RSA Key appears click ‘Close’
Click ‘View Public Key’ and copy the text in the window
Return to your GitHub account page and click the drop-down arrow next to your account avatar (upper-right corner) \(\rightarrow\) select ‘Settings’
Under ‘Settings’ select ‘SSH and GPG Keys’
Select ‘New SSH Key’ \(\rightarrow\) choose a name for the key, like
personal machine
Paste the public key in the window and select ‘Add SSH Key’
1.2.7 Create & Link an R-Project
Click
and select ‘New Project’
At the menu select ‘Version Control’ and then ‘Git’
Enter the url for your fork of the
test-repo
repositoryIf you’ve set-up SSH enter the url as
git@github.com:your.user.name/test-repo.git
If you have not set up SSH enter the url as
https://github.com/your.user.name/test-repo.git
Select ‘OK’ and Git will clone the
test-repo
to your machineOnce the project opens, edit the
README.md
file and commit the changesAdd your initials to the list of initials and save the file
Find the project tabs
in the upper-right pane of RStudio
Select the ‘Git’ tab
The
README.md
file should be listed as a changed fileClick the checkbox next to the filename and then click ‘Commit’
In the Commit dialog, enter a short message in the window detailing the changes you made and click
Commit
Now that the changes have been committed they need to be
Pushed
so that their online counterparts matchClose the
Commit
dialog and pressPush
A window may appear asking for a username and password - ignore this.
After the
Push
is complete a message will appear indicating that the changes have been synced to the Master branch
Submit a
Pull-Request
to sync the changes in your forked version oftest-repo
to my original version oftest-repo
Navigate to the
test-repo
repository page under your accountSelect Pull requests \(\rightarrow\) ‘New Pull Request’
Git will perform a
Diff
to determine which files have been changedAs only the README.md file is changed between the two repos this should be the only file listed.
Select ‘Create Pull Request’
Once the pull request is finished - so is the process to build R/RStudio toolchain for data science