3.5 Saving

As you work on your script, don’t forget to hit Control + S to periodically save your script’s progress! This will only save the current script. If you have multiple scripts open, you should click on each individual tab to save each script. It is possible to “Save All Open Documents” with Ctrl + Alt + S, but I caution against this because you should always review the scripts before blindly saving.

When you decide to take a break from RStudio, whether it’s a 5-min break or 24-hr break, make sure to completely close out of the application before leaving your chair. Trust me on this. If you work on multiple computers, R may create conflicted copies of the same files if you forget to save and close out the R script and session.

Finally, when closing out of RStudio, a message may pop up asking if you would like to save the workspace. The workspace is defined as the current working environment. Saving the workspace retains the user-defined objects for use upon the next R session. In my experience, we often feel better if we choose to hit save. In this case, its usually recommended against to save the workspace simply because users should always start with a clean, empty environment in each R session. Hit save or don’t – just do yourself a favor and start with an empty environment each time you open R Studio (see Fig. 3.18)!