Skip to content
Prev 387278 / 398502 Next

how to manage objects on the working environment

R typically asks you if you want to save your workspace when you quit. If you say yes, your global environment is saved to a file called ".RData" in your current working directory. When you start R it looks for a file of this name in the current working directory and silently loads it.

If you typically use setwd without restoring your original starting directory in your scripts, then the last file saved may not be the file R finds when you start up again.

One problem with .RData files is that they record only part of what you need to pick up where you left off (you still need to re-load whatever contributed packages you were using), but they also silently record your mistakes as well as your correct results and all are restored together. Most experienced R users build R script files as they progress that contain only the R statements that they judge to be desirable/correct, and only create X.RData files (with something in front of the period) intentionally so R will not surprise them by automatically loading them. Relying on R files to restore your progress also makes your work reproducible.
On February 27, 2021 5:39:27 AM PST, Carlos Gonzalez <caghpm at gmail.com> wrote: