16.1 RStudio keyboard shortcuts
The R Markdown format can be used with any editor of your choice, as long as R, the rmarkdown package, and Pandoc are installed. However, RStudio has a deep integration with R Markdown so you can work with R Markdown smoothly.
Like any IDE, RStudio has keyboard shortcuts. A full list can be found under the menu
Tools -> Keyboard Shortcuts Help. Some of the most useful shortcuts related to R Markdown are summarized in Table 16.1.
|Task||Windows & Linux||macOS|
|Insert R chunk||Ctrl+Alt+I||Command+Option+I|
|Knitr document (knitr)||Ctrl+Shift+K||Command+Shift+K|
|Run all chunks above||Ctrl+Alt+P||Command+Option+P|
|Run current chunk||Ctrl+Alt+C||Command+Option+C|
|Run current chunk||Ctrl+Shift+Enter||Command+Shift+Enter|
|Run next chunk||Ctrl+Alt+N||Command+Option+N|
|Run all chunks||Ctrl+Alt+R||Command+Option+R|
|Go to next chunk/title||Ctrl+PgDown||Command+PgDown|
|Go to previous chunk/title||Ctrl+PgUp||Command+PgUp|
|Show/hide document outline||Ctrl+Shift+O||Command+Shift+O|
|Build book, website, …||Ctrl+Shift+B||Command+Shift+B|
Besides, you can press
F7 to spellcheck your document. You can also restart the R session by
Ctrl + Alt + F10 (or
Command + Option + F10 on macOS), which can be helpful for reproducibility, because results are more likely to be reproducible if they are computed from a new R session. This can also be done through the dropdown menu “Restart R and Run All Chunks” behind the “Run” button on the toolbar.