Installation

If you already have R and RStudio great! You can skip this. For the rest of us, fortunately installing R and RStudio is usually pretty straightforward, although it will depend on your operating system. We’ll just hit the main steps, but you will need to go to the R Installation and Administratin for complete help.

There are two main steps to installing R. Downloading and Installing.

  1. Download the most recent version of R, make sure it is for the Operating system you use. A list of mirror sites is found here. It doesn’t matter too much which one you choose, geographically closer ones will be faster and more reliable.

  2. Install R. This will vary greatly depending on your operating system. Just follow the instructions here


  3. Download the installer for RStudio Desktop for your correct operating system here. Make sure you use the open source (free version) and make sure it is the desktop version, unless you are sure you want to set up a server.

  4. Run the installer, again this will vary depending on your operating system.

A Whirlwind Tour

We will get to know RStudio more during the workshop/tutorial, but we’ll touch on the main parts briefly here. If you start up RStudio, you should see something like the screenshot below. Note: If you don’t see a script panel thats normal, you will soon.

Improved multi-variable box plot
Figure 1. Typical layout for R Studio. Exact contents and location may vary.

Console / Command Line

This is where you will typically enter your commands. The Console tab functions just like a normal command line interface for R. There is also a Terminal tab functions just like the terminal (Mac OS or *Nix) or command prompt (Windows).

Click on the Console tab and type > 1 + 1 and return. You should see it respond with the correct answer.

Click on the Terminal tab and type $ ls and return. You should see a list of the files and diretories in your current R project (results may vary).

File Viewer And Editor

If you don’t already have an empty script, click on the New File icon on the top left of your RStudio window and choose R script. This is an R script, there are many like it but this one is yours…

If you write print(1 + 1) in your script and then click on the Source button. This will run the script, the print() function outputs the result to your console.

Storage

This group of tabs is called Storage as the mostly deals with content that is either saved to your disk, or can be downloaded to your disk. We won’t demo them all now, but briefly

  • Files: allows you to navigate and manage the files in your project.
  • Plots: is where your graphs and charts will appear when you create them.
  • Packages allows you to manage the many R packages available to you.
  • Help: displays help for functions and packages in R.
  • Viewer: displays local web content you create.

Memory

This is called Memory because it primarily deals with content that lives in your computer’s memory or RAM. Technically speaking it goes away when you closer RStudio or turn off your computer.

  • Environment: displays all the variables, functions and data currently active in your memory. If you type a <- 42 into your console, you will see the variable a and the value 42 displayed. The broom will clean your environment and let you start fresh.
  • History: Everything you type in the console is stored here. If you choose the last line a <- 42 and click To Source it will copy that to your script…NOICE!! The broom will clean your history. Make sure you don’t lose anything!
  • Connections: Allows you to connect to external databases and data stores.
  • Git: This may not be on your installation, or may have a different name depending on if you have set up versioning and what versioning system you use.