Carlos Gonzalez
2021-Feb-27 13:39 UTC
[R] how to manage objects on the working environment
Good morning! Each time I open a new R session, it appears the same objects that I thought were removed on an old session, but the objects I supposed were saved on the last session never appeared. Thanks! Saludos / Regards Carlos A. Gonzalez Mobile +598 94 234 653 caghpm at gmail.com [[alternative HTML version deleted]]
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:>Good morning! > >Each time I open a new R session, it appears the same objects that I >thought were removed on an old session, but the objects I supposed were >saved on the last session never appeared. > >Thanks! > >Saludos / Regards > >Carlos A. Gonzalez >Mobile +598 94 234 653 >caghpm at gmail.com > > [[alternative HTML version deleted]] > >______________________________________________ >R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see >https://stat.ethz.ch/mailman/listinfo/r-help >PLEASE do read the posting guide >http://www.R-project.org/posting-guide.html >and provide commented, minimal, self-contained, reproducible code.-- Sent from my phone. Please excuse my brevity.