1.5 Starting with a blank canvas

It is vital to restart R regularly, but especially before commencing new work. This is to avoid accidentally using the wrong data or functions stored in the environment. Restarting R only takes a second!

You can restart R by clicking on Session -> Restart R (top menu). There’s also a Keyboard shortcut for it: Ctrl+Shift+F10, but considering how hard it is to use function keys on most laptops these days, that’s hardly a shortcut.

We recommend changing your “Restart R” keyboard shortcut to Windows+R or Cmd+R (Cmd+Shift+R if using RStudio Server or Cloud). This can be done in Tools -> Modify Keyboard Shortcuts.

Furthermore, RStudio has a default setting that is no longer considered best practice. After installing RStudio, you should go change two small but important things in the Tools -> Global Options menu:

  1. Untick “Restore .RData into Workspace on Exit”
  2. Set “Save .RData on exit” to Never
Configuring your RStudio Tools - Global Options to best practise:  **Untick** "Restore .RData into Workspace on Exit" and Set "Save .RData on exit" to **Never**

FIGURE 1.3: Configuring your RStudio Tools - Global Options to best practise: Untick “Restore .RData into Workspace on Exit” and Set “Save .RData on exit” to Never

This does not mean you can’t or shouldn’t save your work in .RData/.rda files. But it is best to do it consciously and load exactly what you need to load, rather than letting R always save and load everything for you, as this could also include broken data or objects.