I've had instances where RStudio gets aborted and I lose my progress.
Is there autosave, at least for the R Scripts?
I think there might be something comparable on Windows. I am using RStudio on Mac.
Autosave for scripts exists. To enable autosave, go to “Preferences” › “Code” › “Saving” › “Auto-save”.
Regardless of the existence of autosave you should get in the habit of saving your script all the time. Case in point, when programming it’s not uncommon for me to save the current file several times per line typed. This takes up no time at all, thanks to shortcuts. It happens completely automatically.
Autosave for session data would kill reproducibility. It would be the ultimate anti-feature. Therefore not only does this feature not exist (per se), it’s actively undesirable.
To avoid losing your progress, write a script instead of executing code directly in the R shell. To save the results of expensive computations, decompose your logic into small blocks, and cache intermediate results.
RMarkdown allows you to do this out of the box; for other scripts, you can approximate the same using readRDS
and loadRDS
, or using a proper reproducibility framework such as ‘targets’.