1.1 Installing On Windows Machines

These instructions are intended for use on personal machines running the Windows 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.1.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 once RStudio is installed.

  • 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

    4. A custom library may be specified by creating an environment variable called R_LIBS and assigning it the path of the desired folder

  • 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.1.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','installr'))

    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.1.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. During the previous step you attempted to install the installr package from the CRAN

  2. We can verify that the package installed successfully by running "installr"%in%installed.packages() in the R console

    1. If the returned value is TRUE you’re all set, skip down to 3)

    2. If the returned value is FALSE skip down to 4)

  3. With the installr package RStudio may be installed from within R by running installr::install.rstudio()

  4. Without the installr package RStudio can be installed from HERE

  5. 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

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

1.1.4 Install LaTeX

A \(\LaTeX\) distribution is required to produce PDF documents. On Windows, MiKTeX is the required \(\LaTeX\) program to work with RStudio.

  1. With the installr package, MiKTeX may be installed from within R by running installr::install.miktex()

  2. Without the installr package MiKTeX can be installed from HERE

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

    2. Otherwise accept all the defaults

  3. Once MiKTeX 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.

  4. 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.1.5 Install Rtools

Mac/UNIX/Linux all include a native set of tools to work with pre-compiled languages (C, C++, FORTRAN). These tools are required for building and installing R packages. Windows does not include these tools, which ordinarily would have to be installed one-by-one. Thankfully, the R Core Team has assembled the Rtools suite to provide this capability. Note, Rtools is not a package! Rather, Rtools is a suite of compiling programs that are distinct from R.

  1. With the installr package, Rtools may be installed from within R by running installr::install.rtools()

  2. Without the installr package Rtools can be installed from HERE

    1. Click on the latest version available, currently Rtools34.exe to download

    2. Note the directory in which Rtools will be installed, typically this is c:\Rtools

    3. On the checkboxes, the ‘Extras’ do not need to be checked - unless you want to rebuild R itself

    4. If you have never installed Rtools before, make sure the ‘edit the system path’ box is CHECKED

    5. Review the list of entries on your system path, the first two should read

      • c:\Rtools\bin

      • c:\Rtools\gcc-4.6.3\bin

    6. If these entries are listed in your path, click OK - and Rtools should begin installing

  3. After the install completes, run devtools::find_rtools() to ensure that R can find Rtools

    1. If this function returns TRUE go on to Install \(\LaTeX\)

    2. If this function returns FALSE follow the steps below to edit the system path

      • Go to Start and perform a search for ‘Environment Variables’

      • If you have admin rights, choose Edit the System Environment Variables otherwise choose Edit Environment Variables For Your Account

      • When the window opens click the Environment Variables button

      • Find the variable named Path \(\rightarrow\) and click Edit \(\rightarrow\)

      • On Windows 10, the path is shown as a bulleted list - Add two new entries at the top c:\Rtools\bin and c:\Rtools\gcc-4.6.3\bin

      • On Windows 8.1 and earlier the path is shown as string, separated by ‘;’ - paste the following to the beginning of the path c:\Rtools\bin;c:\Rtools\gcc-4.6.3\bin

      • If the Path variable doesn’t exist or isn’t editable click New \(\rightarrow\) create a new variable called Path \(\rightarrow\) assign the value c:\Rtools\bin;c:\Rtools\gcc-4.6.3\bin

      • Once again, run devtools::find_rtools() if this still returns FALSE check the directory in which Rtools is located

      • The path entries should lead to the Rtools\bin and the Rtools\gcc-4.6.3\bin folders, wherever they are installed on your machine

      • Once the command devools::find_rtools() returns TRUE, proceed to Install \(\LaTeX\)

1.1.6 Create a GitHub Account

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

    1. Choose a username

    2. Add an email address

    3. Enter a password

  • Once you’ve logged in, perform a search for Auburngrads.

  • GitHub will provide results for all public repositories, files, and user account names containing the search phrase.

  • There should only be one account named Auburngrads - select this to be taken to Auburngrads’ main page.

  • Every GitHub user has a main page showing an overview of their most recently updated repositories (‘repos’). To see Auburngrads’ full list of public repos, click the repositories link.

  • Within the list of Auburngrads’ repos, find the one called test-repo and click the link to go to the Auburngrads/test-repo page.

  • Every public GitHub repo has its own dedicated page listing the files contained within, when each file was most recently updated

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

1.1.7 Install & Configure Git

  1. With the installr package, Git may be installed from within R by running installr::install.git()

  2. Without the installr package Git can be installed from HERE

  3. 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 ‘Git Executable’ window is blank click ‘Browse’ and navigate to C:\Program Files\Git\bin\bin.exe click OK

    4. If the path to git.exe is already listed in the ‘Git Executable’ window, Git has been installed correctly

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

    1. Open Start and search for the ‘Git Bash’ application, open the 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 Git Bash

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

    1. 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.com 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’