Two useful RStudio IDE functionalities to improve your day-to-day R programming workflow--and more.
Main
The RStudio IDE (integrated development environment) is a powerful open-source application that is a de facto standard tool in the R community for writing programs and developing software. Although many casual R users are unaware of them, the RStudio IDE is in fact packed with useful functionalities that can significantly improve your programming workflow.
Here I present two such functionalities, namely, keyboard shortcuts and code snippets.
1. Keyboard shorcuts
RStudio IDE offers a large number of keyboard shortcuts to help you to quickly carry out some common tasks. Some of the keyboard shortcuts I find useful are as follows:
Shortcut
Effect
Ctrl + 1
Move focus to Source Editor
Ctrl + 2
Move focus to Console
Ctrl + L
Clear Console
Ctrl + Enter
Run the current line/selection on Source Editor
Ctrl + Shift + C
"Comment out" the current line on Source Editor
Ctrl + Shift + N
Open a blank R script
Ctrl + Shift + M
Insert a magrittr "pipe" operator, %>%
Ctrl + Shift + F10
Restart R Session
Alt + -
Insert assignment operator
Alt + Shift + K
Open Keyboard Shortcut Reference window
To see the full list, use the keyboard shortcut Alt + Shift + K on your RStudio IDE to open up the Keyboard Shortcut Quick Reference window. Alternatively, you can check out this article on RStudio's Support website.
Although you cannot add new keyboard shortcuts, it is possible to customize the keyboard shorcuts to make it easier for you to use. Take a look at this article on customizing keyboard shortcuts for details.
2. Code snippets
The RStudio IDE offers "code snippets", i.e. text macros that can quickly insert commonly used snippets of R code. The way it works is simply that, on Source Editor, you 1) type the snippet keyword and 2) hit the <Tab> button to get the full code snippet. It is similar to code autocompletion, but more powerful and flexible.
Some of the predefined code snippets include:
lib: to load a library/package
library(${1:package})
fun: to define a new function and assign it to a name
${1:name} <- function(${2:variables}) {
${0}
}
shinyapp: to create a new shiny application
library(shiny)
ui <- fluidPage(
${0}
)
server <- function(input, output, session) {
}
shinyApp(ui, server)
You can view the full list of the currently available code snippets at: **Menu bar: Tools > Global Options > Code > Edit Snippets**.
In addition, you can add your custom code snippets on the **Edit Snippets** window. Read [this article](https://support.rstudio.com/hc/en-us/articles/204463668-Code-Snippets) on RStudio's Support website to learn more about code snippets.
### ... And more
Of course, these are only a tip of an iceberg when it comes to what the RStudio IDE offers to its users to improve their programming experience. I invite you, therefore, to look through [this list of articles on using the RStudio IDE](https://support.rstudio.com/hc/en-us/sections/200107586-Using-the-RStudio-IDE) to learn more about how to take full advantage of this powerful tool!
### Resources
* ["Code Snippets"](https://support.rstudio.com/hc/en-us/articles/204463668-Code-Snippets) by J.J. Allaire
* ["Customizing Keyboard Shortcuts"](https://support.rstudio.com/hc/en-us/articles/206382178-Customizing-Keyboard-Shortcuts) by Kevin Ushey
* [RStudio website](https://www.rstudio.com/)
* ["Using the RStudio IDE" article list](https://support.rstudio.com/hc/en-us/sections/200107586-Using-the-RStudio-IDE) on the RStudio Support website
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Summary
Two useful RStudio IDE functionalities to improve your day-to-day R programming workflow--and more.
Main
The RStudio IDE (integrated development environment) is a powerful open-source application that is a de facto standard tool in the R community for writing programs and developing software. Although many casual R users are unaware of them, the RStudio IDE is in fact packed with useful functionalities that can significantly improve your programming workflow.
Here I present two such functionalities, namely, keyboard shortcuts and code snippets.
1. Keyboard shorcuts
RStudio IDE offers a large number of keyboard shortcuts to help you to quickly carry out some common tasks. Some of the keyboard shortcuts I find useful are as follows:
Ctrl + 1
Ctrl + 2
Ctrl + L
Ctrl + Enter
Ctrl + Shift + C
Ctrl + Shift + N
Ctrl + Shift + M
magrittr
"pipe" operator,%>%
Ctrl + Shift + F10
Alt + -
Alt + Shift + K
To see the full list, use the keyboard shortcut
Alt + Shift + K
on your RStudio IDE to open up the Keyboard Shortcut Quick Reference window. Alternatively, you can check out this article on RStudio's Support website.Although you cannot add new keyboard shortcuts, it is possible to customize the keyboard shorcuts to make it easier for you to use. Take a look at this article on customizing keyboard shortcuts for details.
2. Code snippets
The RStudio IDE offers "code snippets", i.e. text macros that can quickly insert commonly used snippets of R code. The way it works is simply that, on Source Editor, you 1) type the snippet keyword and 2) hit the
<Tab>
button to get the full code snippet. It is similar to code autocompletion, but more powerful and flexible.Some of the predefined code snippets include:
lib
: to load a library/packagefun
: to define a new function and assign it to a nameshinyapp
: to create a new shiny applicationui <- fluidPage( ${0} )
server <- function(input, output, session) {
}
shinyApp(ui, server)