Help with RStudio

This page provides links to introduce you to the RStudio environment.

RStudio Basics

The R Environment

Managing window panes

Did you lose track of one of your window panes? Use the View tab in the top bar to return to a view with all panes

Show All Panes

Change RStudio color theme

Is the white RStudio background burning your retnas? Need a change of scenery? No need to go outside!

In the top bar, go to Tools > Global Options, and then select “Appearance”:

Change appearance

RMarkdown keyboard shortcuts

You can find me mashing the following keys in Windows:

Shortcut Keys (Windows) Keys (MacOS)
Run a line of code (With typing cursor on line) ctrl + enter (With typing cursor on line) cmd + enter
Run a chunk of code (With typing cursor in chunk) ctrl + shift + enter (With typing cursor in chunk) cmd + shift + enter
Create a new chunk ctrl + alt + i cmd + option + i
Type a pipe ctrl + shift + m cmd + shift + m
Type an assignment operator alt + - option + -
Stop running (In Console) esc (In Console) esc

Session information and help documentation

If for some reason your code is hitting an error, here are some useful commands you might run in your RStudio Console to help troubleshoot:

Function Documentation

Command: ?functionName

What it does: Pulls up the documentation for whatever you type in place of functionName, and displays it in the Help window. A function’s documentation is often (but not always) the final word on how a function is meant to behave in R. It will provide information on the function’s arguments (and their default values), the resulting output (“Values”), and will give you examples of how to implement that function.

Session information

Command: sessionInfo()

What it does: If you’re experiencing issues with a certain package, maybe it’s time for an update. You can check your current version of R using this command. Find information on specific packages by using the argument ‘package = packageName’.

You can also find which version of RStudio you have by running RStudio.Version()

View Traceback

Command: traceback()

What it does: If your code keeps hanging up on an error, you can often find clues as to why it’s happening by viewing the underlying code that’s causing your code to halt. Traceback will print the list of functions that were called before the error occurred. It’s literally “tracing your steps” right before the error happened. The language itself in the traceback is usually pretty cryptic and hard to read at first. Don’t let that stop you from looking at it when you encounter problems.

Memory storage information

Command: object_size()

What it does: For the purposes of this lab, you most likely won’t need to worry about your computer’s RAM. Nevertheless, the nerds among us might find it interesting to inspect the size of an object that we’ve saved to our R Environment. Use object_size(objectName) to inspect a given object. Alternatively, inspect overall RAM usage and limitations with memory.size() and memory.limit().

Extended resource guide to RStudio

R Studio will be the launching pad for all of our lab assignments in this course.

The RStudio environment itself can feel overwhelming at first. Luckily, there are excellent resources already available to help get you acquainted: