Installation

To download R you can visit R’s homepage and follow the link for your operating system.

Alternatively if you trust clicking a link from here to download R you can click one of the following:

RStudio

The basic RGui in all of the systems is fairly minimalistic and doesn’t provide too many features. We recommend RStudio to provide a much better environment to use R. Don’t let the “Version 0.99” fool you - it is one of the best interfaces to R out there right now. It also happens to be cross-platform so no matter which operating system you’re using RStudio is available. You can download the latest version of RStudio here. If you get everything installed correctly and get it up and running the basic layout looks something like this:

That screengrab was shamelessly stolen from the RStudio website. The look and feel is consistent across all platforms though so you should feel comfortable no matter where you run RStudio from.

Testing that R works

We’ll show what it looks like for an RStudio user to test R and provide the necessary changes at the bottom for Mac and Linux users. Once installed open up “RStudio”. You should be presented with something that looks very similar to this:

Test that you can use the console by typing something like 2+2

2+2
## [1] 4

Ok, if that worked, try to write something simple in a script file and submit it to the console

print("Hello World")
## [1] "Hello World"

Now let’s install some packages that we’ll need for the workshop. You’ll need an active internet connection for this.

Copy and paste the following line into your script (or console): install.packages(c("ggplot2", "dplyr", "tidyr", "lubridate"))

The console will display a bunch of stuff and hopefully it looks similar to:

We’ll load one of the packages we installed and test that it works. Paste the following lines into the console. The result should be a plot that looks similar (but not the same as) the plot below:

library(ggplot2)
qplot(rnorm(100))

If you got that plot then you are ready to go!

Mac users

Essentially all of the details above are the same except that you use “command” + “enter”.

Linux users (not using RStudio)

To use basic R you just need to open up your preferred terminal and type R. If this doesn’t work then you’ll need to add R’s path to your path. The commands you’ll want to use to test are the same. However, you’ll see a lot more output when installing the packages because instead of downloading binaries (like Windows and Mac do) you end up compiling the packages directly. Don’t worry about having more output - this is to be expected.

Linux users (using RStudio)

There are binary (deb and rpm) and source files for Rstudio available for Linux. In addition, if you use Ubuntu, you can add ppa:marutter/rrutter and ppa:marutter/c2d4u using add-apt-repository - this will provide binaries for R and many R packages that can have some tricky dependencies and can make your life much easier.