Keyboard shortcuts in R
A few common shortcuts in RStudio can save you from typing a lot of extra keystrokes.
Execute a command
Command + Enter
Run a section of code in your R script.
Input an assignment character
Option + -
Input a <-
at your cursor to assign output to a variable.
Comment multiple lines
Command + Shift + C
Highlight one or multiple lines of code and use this shortcut to comment them all out, preventing that section from executing.
Input a pipe character
Command + Shift + M
When using the tidyverse
library. Input the character sequence %>%
, used to chain together different functions for more complex operations.
Insert a section label
Command + Shift + R
Prompt the user for a new section label, then insert the label at the cursor. Section labels show up in the document outline.