RStudio is a popular integrated development environment (IDE) for R. It provides a user-friendly interface for R programming and data analysis. Here’s a RStudio cheat sheet covering common features and shortcuts:
RStudio Interface
- Console:
Ctrl + Enter
: Run current line or selection.Alt + Enter
: Run current line and insert a new line below.
- Script Editor:
Ctrl + Shift + N
: Create a new script.Ctrl + S
: Save script.Ctrl + /
: Comment/uncomment selected lines.
- Environment Pane:
- View and manage objects, data frames, and packages.
- Files Pane:
- Explore and manage files in the working directory.
- Plots Pane:
- Display and interact with plots.
Running Code
- Run Entire Script:
Ctrl + Alt + R
: Run the entire script.
- Run Chunk:
Ctrl + Alt + C
: Run the current code chunk.
- Run Previous Commands:
Ctrl + Up Arrow
orCtrl + Down Arrow
: Navigate through previous commands.
Help and Documentation
- Access Help:
?function_name
orhelp(function_name)
: Open help documentation.
- View Function Source:
F2
orCtrl + Click
: View source code of a function.
Version Control
- Git Integration:
- RStudio has built-in Git integration for version control.
- Commit Changes:
Alt + Shift + M
: Stage and commit changes.
Shiny Apps
- Run Shiny App:
Ctrl + Shift + Enter
: Run the active Shiny app.
- Stop Shiny App:
Esc
: Stop the running Shiny app.
Markdown Documents
- Knit Document:
Ctrl + Shift + K
: Compile a Markdown document.
- Preview Document:
Ctrl + Shift + I
: Preview the compiled document.
Keyboard Shortcuts
- Show Keyboard Shortcuts:
Alt + Shift + K
: Display the list of keyboard shortcuts.
Integrated Terminal
- Open Terminal:
Alt + Shift + R
: Open the integrated terminal.
Miscellaneous
- Search in Script:
Ctrl + F
: Search for text in the script.
- Replace in Script:
Ctrl + H
: Replace text in the script.
- Run Code Section:
Ctrl + Enter
with text selected: Run the selected code.
- Toggle Comment:
Ctrl + /
: Comment/uncomment selected lines.
This cheat sheet provides a quick reference for common features and shortcuts in RStudio. For more detailed information, refer to the official RStudio documentation.