4 Getting to know what is what

Written by Annie Collins and last updated on 7 October 2021.

4.1 Introduction

In this lesson, you will learn how to:

  • Navigate the RStudio interface; and
  • Run R code using RStudio

Prerequisite skills include:

  • Downloading R and RStudio (see previous lesson).

4.2 Basic Layout

When you open RStudio on desktop, it should look fairly similar to RStudio Cloud (the internet-based version of RStudio that you likely used to load this module). There are four main panes:

  • Scripts: the upper left corner of RStudio Desktop is where any R Script or R Markdown files will appear when you open them. You can open more than one at once, in which case they will appear in separate tabs. You will also see relevant buttons for each document, such as search, save, and run.
  • Environment: this is where all your stored variables (vectors, data frames, models, plots, etc.) will be shown by name and type. In the “History” tab, you will also find a list of all code that you have run recently.
  • Console: the console is where code is run (either individual lines typed directly into the console, or blocks of code run from a script file) and its output is generally produced. While it is usually good practice to write your code in a script or markdown file, sometimes it is easier to run certain functions as single lines of code (actions that you won’t need to reference later on, since the individual commands can be hard to find once more code is run). Most basic code output is also shown in the console, like data summaries, model summaries, data previews, etc.
  • Files: This pane displays all the files in your working directory, which is a folder stored on your computer that RStudio will use as its main directory for opening and saving files. It becomes very useful when you’re working on a project that involves multiple scripts, files, external data sets, or graphics that contribute to your final project and all need to be easily accessible from the same place.

See the video below for a more in-depth tour of the RStudio interface.

4.3 More Advanced Features

You’ll notice that there are several tabs and buttons within each of these areas that I haven’t mentioned yet. These all serve their own specific purpose which will become more clear as you start exploring the interface and running code yourself. Don’t worry too much about everything that is going on. When a person steps into a plane cockpit for the first time it can be overwhelming and it’s the same here - it’s normal to not know where to look. Before too long you’ll be navigating around RStudio comfortably.

4.4 Next Steps

The best way to learn R is to use R. In the next lesson we’re going to walk you through a couple of exercises of things that you could accomplish with R once you’re a little more familiar with it. We hope that you find it motivating and exciting.