RStudio Shortcuts and Settings
[This article was first published on Albert Rapp, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
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 withShift + Tab
- Multiple cursors with
Alt + click
- Use
Ctrl + 1
andCtrl + 2
to switch between the console and the current script window (eliminates the need to use the mouse for navigation)
File and Text Search
- Use
Ctrl + .
to search for files AND functions - Use
Ctrl + F
to search for specific text within the currently open file - Use
Ctrl + Shift + F
to search for text within all files in the current project
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,
- Run all code chunks (
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:
- 3 Minute Wednesdays: A weekly newsletter with bite-sized tips and tricks for R users
- Insightful Data Visualizations for “Uncreative” R Users: A course that teaches you how to leverage
{ggplot2}
to make charts that communicate effectively without being a design expert.
To leave a comment for the author, please follow the link and comment on their blog: Albert Rapp.
R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.