[R] PowerCut Killed R - is my code retrievable?

Polwart Calum (County Durham and Darlington NHS Foundation Trust) calum.polwart at nhs.net
Thu Aug 20 21:46:11 CEST 2009

Rolf Write:
> 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().

Was hoping there was some thing like that... but like you say it wasn't a planned exit so its not there


Barry wrote:

> 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.

Yeh thats what I was expecting to happen.  I can't actually remember but I think it was gedit that I had open although sometimes I use kate.  Neither have autorecoverry as I now know.  Both can recover (possibly) files that had once been saved but it seems I never saved it - nit was literally just a big temporary, editable clipboard!

> 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).

It seems only if you hit save once then you may get temporary copies...!

I've never liked emacs for other programming stuff - but will take another look at it.

Ted wrote:
> To follow up on what Barry wrote above: Don't be put off by the
> recommendation to use EMACS (which is not to everyone's taste).

Took the words out of my mouth

>I use vim, which does much the same sort of thing: there is a hidden
> ".whatever.swp" file which contains a back-trackable history of
> the editing changes that have been made to the file. So, if you get
> a crash, on re-opening the file in vim you are asked if you want to
> "recover". The ".swp" file is *not* zapped by a reboot!

Good to know.  I used to use vi quite a lot in my command line linux days.
These days it seems cumbersome on my linux PC but works fine on my server!
Must be a configuration issue...

> Again, what I routinely do (in Linux) when developing R code is to
> have two terminal windows open. In one I am running R. In the other,
> beside it, I am editing a file of R code. To run code in R that has
> been entered in the "code" window, I just highlight it with the
> mouse in the "code" window, and then paste it into the "R" window.

Exactly what I was doing.  Sounds like emacs with ESS has this even
slicker - highlight and run.  I just need to save the stuff!

Ellison wrote:
> Use a text editor or something specific to R like Tinn-R and _save early
> and often_.

Tinn-R is window$ only.  I've played with RKWard and found it cumbersome plus it doesn't put my commands and its commands together so you don't get a command line History.

Looking at sciViews-K just now.

I currently use Eclipse as my DIE for PHP programming so I'll look at that too.  I guess where I'm struggling is I don't really rate what I'm doing as programming becasue I'm not writing R plugins just some functions... Mind you just having some R context sensitive text / syntax highlighting may be an advantage.

Hans wrote:
> What about a version control system to (locally) save the different
> stages of your script files?
> (I use git but Subversion (SVN) may be easier and do the job).

My changes were typically one line at a time - and re-run it.  I could remember what it was if it didn't do it (or use undo).  But if this gets big then SVN etc might be worth it.  I have no hands on expereince with GIT - one of my PHP projects has been discussing moveing to GIT / Bazzar for about 6 months.  I see the advantage for them as they have multiple coders - is there some advanatge i might have missed for a lone programmer (sorry going well OT).

Clearly either doesn't work if I don't save the file!

Thanks BTW for all the posts back - one of my best responded to queries!



This message may contain confidential information. If yo...{{dropped:21}}

More information about the R-help mailing list