Chapter 6. Workflow: Projects
One day you will need to quit R, go do something else, and return to your analysis the next day. One day you will be working on multiple analyses simultaneously that all use R and you want to keep them separate. One day you will need to bring data from the outside world into R and send numerical results and figures from R back out into the world. To handle these real-life situations, you need to make two decisions:
-
What about your analysis is âreal,â i.e., what will you save as your lasting record of what happened?
-
Where does your analysis âliveâ?
What Is Real?
As a beginning R user, itâs OK to consider your environment (i.e., the objects listed in the environment pane) âreal.â However, in the long run, youâll be much better off if you consider your R scripts as âreal.â
With your R scripts (and your data files), you can re-create the environment. Itâs much harder to re-create your R scripts from your environment! Youâll either have to retype a lot of code from memory (making mistakes all the way) or youâll have to carefully mine your R history.
To foster this behavior, I highly recommend that you instruct RStudio not to preserve your workspace between sessions:
This will cause you some short-term pain, because now when you restart RStudio it will not remember the results of the code that you ran last time. But this ...
Get R for Data Science now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.