Introduction to RStudio

Learning Recap

At the end of this lesson, you should understand:

  • what the different tabs in each of the panes of RStudio do
  • what is in each menu item in Rstudio and have a general sense of functionality available

RStudio is more than a graphical user interface for R. It is an integrated development environment (IDE), that is a full service application for supporting software development. It can perform multitudes, so much more than what most R users need.

It is the supermarket of R functionality. Like a supermarket, there are parts of RStudio you will visit frequently and parts you will rarely if ever use. After 12+ years of using RStudio on a near daily basis, there are several parts of it that I continue to be unfamiliar with! Ths is okay - clearly, I have not needed those parts. You will come to find what sections you will need most over time and practice.

Still, it helps to have a guided tour. Let’s dive into this.

Note

Recall that R is separate from RStudio. R is the actual interpreter that does all the amazing stuff. RStudio is a user interface (that is also amazing for different reasons). I have seen many papers reference RStudio (“We used R version 1.0.2…”) like it was R, an embarassing error. Don’t fall into this trap.

The Panes

Here is a simplified schematic:

These can be rearranged, but for this class, we will use the default arrangement.

The Console/Terminal/Background Jobs

Default location: left or bottom left

Tab Purpose
Console where R commands are actually done
Terminal use a terminal language such as bash or the windows command prompt
Background jobs usual pacakage installation

In this workshop, we will only be using the Console.

Files/Plots/Packages/Help/Viewer/Presentation

Default location: bottom right

Probably the most useful pane - we will be here frequently!

Tab Purpose
Plots view plots
Files explore your file system
Packages install, update and load packages
Help helps files & examples
Viewer for previewing websites
Presentation for previewing presentations

We will not be using the Viewer or Presentations tabs in this workshop.

What are Packages?

These make the world go around in R. All of R consists of packages or libraries that have certain functionality associated with them. Some of are maintained by the R core team, others are maintained by outsiders. All packages are open source and most are a volunteer effort. When you open R, several packages are loaded automatically: base, datasets, graphics, grDevices, methods, stats, utils.

We will talk about package installation and usage later in this course/workshop.

Environment/History/Connections/Build/Git/Tutorial

Tab Purpose
Environment objects created and existing in your current R session
History previous R command run
Connections to connect to an external database
Build for building R packages and other large projects
Git only visible if you’ve initialized a git repository
Tutorial tutorials build by Posit (very helpful)

here

Our Scripts Pane

default location: upper left

These are all the files we create and edit: .R, .Rmd, .txt, etc. When we open files from the “Files” pane, this is where it shows up.

The Upper Menu Items

File

  • Opening and/or creating files
  • Opening and/or creating projects
  • Recent files, recent project
  • …standard file functionality

Edit

  • Copy, paste, find
  • Very handy “find in files” feature!

Code

  • Incredible useful set of commands
  • Some are very simple (e.g. “comment lines”), others are complex (e.g. “rename in scope”)
  • Over time, you will learn what these mean and perhaps make use of them (if you don’t, that is okay)

View

  • Rearrange panes
  • Zoom in/out
  • Overall not that useful, except for the shortcuts

Plots

  • (self explanatory)

Session

  • Very handy for restarting your R session
  • Manually set the working directory

Build

  • Advanced tools for building packages, websites, et cetera. I’ve never visited this part of the supermarket.

Debug

  • Tools for debugging code (removing scripting errors). We will not use this in the workshop! But you can learn more about it here.

Profile

  • For code profiling (checking how long it takes your code to run). We will also not be using this in the workshop. This is part of the supermarket I rarely visit.

Tools

  • Some handy utility function. I mostly use this menu item to set preferences via “Global Options”.

Help

  • Mmore utility functions. You can check for RStudio updates here, access community help forum, and other forms of documentation in addition to standard help files.

more

Rstudio has a massive number of keyboard shortcuts. You can find them in the menu (Help –> Cheat Sheets) and summarized in this cheat sheet