1.6 Installation and setup of R

Below some notes on the installation and setup of R and relevant packages on your own computer:

  1. Install Rtools for Windows machines from CRAN (https://cran.r-project.org/bin/windows/Rtools/). If you are using OS X, you will need to to install XCode, available for free from the App Store. This will install a compiler (if you don’t have a compiler installed) which will be needed when installing packages from GitHub that require compilation from C++ source code.
  2. Install the latest version of R from CRAN (https://cran.r-project.org/).
  3. Install the latest version of RStudio (https://www.rstudio.com/products/RStudio/). RStudio is the editor we’ll rely on, i.e. we’ll write code in RStudio which is subsequently sent to and run within R.
  4. Install the latest versions of any various packages we need (we’ll do that on the fly) with install.packages("packagename"). You can also update your packages by running “update.packages(ask = FALSE)” in the R commandline.

  5. Load all necessary packages with library(packagename).

  6. You may also read up on how to create and “knit” an RMarkdown files. Essentially, such files allow you to integrate the analyses you conduct with the text you write which is ideal for reproducability. Here is an intro to the concept and a simple example: http://rmarkdown.rstudio.com/lesson-1.html.