RStudio Shortcuts and Settings

I often get asked about RStudio settings. So that’s why I’ve decided to share my settings and all of my favorite RStudio tricks.
Author

Albert Rapp

Published

June 2, 2024

RStudio is the premier way to write R code. It is very user-friendly as it’s super easy to set up. But it also has a lot of pretty advanced features. In today’s blog post I’ll give you a list of my favorite RStudio tricks and shortcuts. If you want to see detailed explanations, you can check out my video here:

RStudio Theme Setting

  • Use a dark theme for better visibility
  • Enable rainbow parentheses and rainbow indentations to improve code legibility
  • Increase the font size for better readability

RStudio Settings

  • Set up RStudio with the file on the left and the console on the right (as the console is more important than the environment tab for most use cases)
  • Do not save anything into your environment when closing RStudio (Always start with a clean slate to avoid mistakes caused by leftover variables from previous sessions)

Coding Basics

  • Use Ctrl + Shift + M to create a pipe (|>) without typing special characters
  • Use Ctrl + Enter to execute separate lines
  • Use Ctrl + Shift + Enter to execute an entire file
  • Select a specific part of the code and use Ctrl + Enter to execute only the selected portion (useful for debugging pipe chains step by step)
  • Open function documentation with F1
  • Move lines of code with Alt + arrows
  • Indent with Tab and unindent with Shift + Tab
  • Multiple cursors with Alt + click
  • Use Ctrl + 1 and Ctrl + 2 to switch between the console and the current script window (eliminates the need to use the mouse for navigation)

Command Palette and more shortcuts

  • Use Ctrl + Shift + P to execute commands
  • Helpful for using shortcuts that you might have forgotten (like expanding all folds or going to a file)
    • Run all code chunks (Ctrl + Alt + R)
    • Render current document (Ctrl + Shift + K)
    • Restarting R Session (Ctrl + Shift + F10)
    • Styling code with the styler package
    • Running your Golem apps,

Conclusion

Feel free to share your favorite shortcuts, settings, or any other tips I might have missed in the comments below. Have a great day and see you next time. And if you found this helpful, here are some other ways I can help you:


Enjoyed this blog post?

Here are three other ways I can help you:

3 Minutes Wednesdays

Every week, I share bite-sized R tips & tricks. Reading time less than 3 minutes. Delivered straight to your inbox. You can sign up for free weekly tips online.

Data Cleaning With R Master Class

This in-depth video course teaches you everything you need to know about becoming better & more efficient at cleaning up messy data. This includes Excel & JSON files, text data and working with times & dates. If you want to get better at data cleaning, check out the course page.

Insightful Data Visualizations for "Uncreative" R Users

This video course teaches you how to leverage {ggplot2} to make charts that communicate effectively without being a design expert. Course information can be found on the course page.