Polwart Calum (County Durham and Darlington NHS Foundation Trust)
2009-Aug-19 21:57 UTC
[R] PowerCut Killed R - is my code retrievable?
I've been tweaking code for several days on and off in R, cut and pasting in from a text editor (I just leave them open all the time). I think I got something that was usable but then a powersurge tripped the fuses and unfortunately the machine I was working on doesn't have a UPS. Does R hold the command data in cache some place? I've purposefully not opened R since the crash so that if it did I don't over write it? I guess what I'm wanting is the equivalent of the linux up arrow which repeats the last line. i know that exists in R but from what I recall it didn't work when you close the R session. Is that stored in a hidden file someplace that I could copy? Its not a huge piece of code or anything - but it was code I tweaked over several stages as I'm new to R and so it was part of my learning process. Also - is there a better way for the future? I know some people use IDE's but is that for serious programming or for building a small function and tweaking it? Thanks Calum ******************************************************************************************************************** This message may contain confidential information. If yo...{{dropped:21}}
On 20/08/2009, at 9:57 AM, Polwart Calum (County Durham and Darlington NHS Foundation Trust) wrote:> I've been tweaking code for several days on and off in R, cut and > pasting in from a text editor (I just leave them open all the > time). I think I got something that was usable but then a > powersurge tripped the fuses and unfortunately the machine I was > working on doesn't have a UPS. > > Does R hold the command data in cache some place? I've > purposefully not opened R since the crash so that if it did I don't > over write it? > > I guess what I'm wanting is the equivalent of the linux up arrow > which repeats the last line. i know that exists in R but from what > I recall it didn't work when you close the R session. Is that > stored in a hidden file someplace that I could copy? > > Its not a huge piece of code or anything - but it was code I > tweaked over several stages as I'm new to R and so it was part of > my learning process. > > Also - is there a better way for the future? I know some people > use IDE's but is that for serious programming or for building a > small function and tweaking it?If you've been cut-and-pasting from a text editor, then your commands *might* be in the file .Rhistory. Unfortunately this history gets saved only when you exit R (and by default only when you also say ``yes'' to saving the workspace) or if you explicitly savehistory(). After a powersurge, the R workspace and history almost surely will not be saved, so it is highly probable that you are SOL. Unless you closed the R session (and save the workspace) before the power cut. Bummer. Good luck. cheers, Rolf Turner ###################################################################### Attention:\ This e-mail message is privileged and confid...{{dropped:9}}
On Wed, Aug 19, 2009 at 10:57 PM, Polwart Calum (County Durham and Darlington NHS Foundation Trust)<calum.polwart at nhs.net> wrote:> I've been tweaking code for several days on and off in R, cut and pasting in from a text editor (I just leave them open all the time). ?I think I got something that was usable but then a powersurge tripped the fuses and unfortunately the machine I was working on doesn't have a UPS.So you were just using the text editor as a scratch pad, and not saving it? A half-decent text editor should be saving things to disk as you go. For example, in emacs, if your emacs dies while editing a file then when you restart it, it will notice and offer to restore it from its "restore" file. If you were using emacs you might have files like #foo.R# which are emacs' auto-restore files. Other editors might do other things - possibly leaving files in /tmp on a Linux system (but they might get zapped by a reboot).> Also - is there a better way for the future? ?I know some people use IDE's but is that for serious programming or for building a small function and tweaking it?Tip #1 is save your text file scratchpads! Tip #2 is save your R session regularly (just do 'save.image()' and it will save your current R session objects in a .RData file) Tip #3 is you could use emacs + ESS as an IDE - you run R within emacs, giving you cut n paste of code, syntax highlighting, session transcripts, and emacs' protection from data loss on a crash! Barry
>>> "Polwart Calum (County Durham and Darlington NHS Foundation Trust)"<calum.polwart at nhs.net> 08/19/09 10:57 PM >>>>is there a better way for the future?Use a text editor or something specific to R like Tinn-R and _save early and often_. Even if your editor has an autosave. And use savePlot on your graphs too, from within the code - don't save them manually from the menus 'cos you won't remember which file was which plot. That may sound like paranoia, but believe me - they really are out to get you. Paranoia does have a brighter side, though; there is nothing quite like being able to go back to the saved code and re-do the complete statistical analysis from start to finish in about two minutes exactly as originally carried out when your research colleagues tell you cheerily that they found the typo in their raw data... S ******************************************************************* This email and any attachments are confidential. Any use...{{dropped:8}}