1.6 Restart R regularly
Have you tried turning it off and on again? It is vital to restart R regularly. Restarting R helps to avoid accidentally using the wrong data or functions stored in the environment. Restarting R only takes a second and we do it several times per day! Once you get used to saving everything in a script, you’ll always be happy to restart R. This will help you develop robust and reproducible data analysis skills.
You can restart R by clicking on
Session -> Restart R(top menu).
Furthermore, RStudio has a default setting that is no longer considered best practice (Figure 1.3).
After installing RStudio, you should go change two small but important things in
Tools -> Global Options:
- Uncheck “Restore .RData into Workspace on startup”
- Set “Save .RData on exit” to Never
This does not mean you can’t or shouldn’t save your work in
But it is best to do it consciously and load exactly what you want to load.
Letting R silently save and load everything for you may also include broken data or objects.