• 1. Orientation to RStudio

Motivating scenario: You have just downloaded R and RStudio, and want to understand all the stuff that you see when you open RStudio.

Learning goals: By the end of this sub-chapter you should be able to

  1. Identify the source pane and what to do there.
  2. Identify the terminal pane and what to see and do there.
  3. Identify the environment / history pane, what to see and do there, and how to navigate tabs in this pane.
  4. Identify the file / plot / help / viewer pane, what to see and do there, and how to navigate tabs in this pane.

Above, you ran R in this web browser, but more often you will work with R in RStudio. When you open RStudio for the first time, you will see three primary panes. The one on the left works identically to the basic R console. Navigating to ‘File > New File > R Script’ opens a new script and reveals a fourth pane.

R Scripts are ways to keep a record of your code so that you can pick up where you left off, build on previous work, and share your efforts. We will introduce R Scripts more formally soon!

Like the R console above (and all computer languages) RStudio does not “know” what you wrote until you enter it into memory. There are a few ways to do this, but our preferred way is to highlight the code you intend to run, and then click the Run button in the top right portion of the R script pane. Alternatively, press Ctrl+Return for Windows/Linux or ⌘+Return on OS X.

**Figure:** A screenshot of the RStudio interface divided into four labeled panes.  - **Pane 1 (top-left):** The R script editor contains code. - **Pane 2 (bottom-left):** The console shows the execution of the script.  - **Pane 3 (top-right):** The environment panel lists two variables in R's working memory.- **Pane 4 (bottom-right):** The plots panel displays the  plots our code made.
Figure 1: More panes = less pain. A brief tour of RStudio’s panes.

Figure 1 shows what your RStudio session might look like after doing just a little bit of work: