RStudio shortcuts (Windows) – for cleaner and faster coding

RStudio has a number of keyboard shortcuts that make for cleaner and faster coding. I put all the Windows shortcuts that I use onto a single page so that I can pin them next to my computer.

RStudio shortcuts

(PDF)

You can also access the list of shortcuts with Shift + Alt + K so the sheet may be redundant to many. However, I found that having a physical copy next to my computer helped a lot while I was still learning the shortcuts.

Some favourites of mine are:

Using code sections/chunks – Use Ctrl+Shift+R to insert a code section and a popup box will appear for you to name that section. Ctrl+Alt+T runs the current code section. When you are done working on a code section you can ‘fold’ it up to improve the readability of your file (Alt+L is fold current code section, Alt+O is fold all sections).

Re-running code quickly – Ctrl + Shift + P will execute the same region of code that was just previously run with the changes made since then.

Deleting/moving stuff faster – Ctrl+D deletes an entire line. Ctrl + backspace deletes the current word as in most word processing software. Alt + up/down moves code up and down lines in the console while Shift+Alt+up/down copies lines up/down.

Switch between plots – To toggle between plots use Ctrl+Shift+PgUp/PgDn (It’s a lot faster than using the arrows above the plots!)