From maechler at stat.math.ethz.ch  Mon Dec 19 12:39:39 2011
From: maechler at stat.math.ethz.ch (Martin Maechler)
Date: Mon, 19 Dec 2011 12:39:39 +0100
Subject: [Rd] Saving nothing with save()
In-Reply-To: <CANVKczNM=0L+8RbN_rwfG898euRu9y-jFUdgWtQ9RRZk1h71-w@mail.gmail.com>
References: <CANVKczNM=0L+8RbN_rwfG898euRu9y-jFUdgWtQ9RRZk1h71-w@mail.gmail.com>
Message-ID: <20207.8827.526125.480848@stat.math.ethz.ch>

>>>>> Barry Rowlingson <b.rowlingson at lancaster.ac.uk>
>>>>>     on Sun, 18 Dec 2011 01:32:52 +0000 writes:

    > Scenario: Here I am working away in R. I've got results
    > that prove global warming is anthropogenic and also the
    > solution for producing limitless carbon-neutral energy
    > from nuclear fusion. Its been a good day.

    > So, I want to save my work. I don't want to overwrite my
    > current .RData, so I save it to another file:

    > save(file="prize.RData") # just need to email this to the
    > Nobel committee q() Save workspace image? [y/n/c]: - "no"
    > I don't want to save the workspace image, I just saved
    > everything to "prize.RData". But gee, it did seem to do
    > that quite quickly considering the volume of evidential
    > data in my work. My unix shell prompt returns.

    > Uh oh. See what I did there? I typed 'save' when I meant
    > 'save.image'.  What does that give me?

    >  A 42 byte, empty, latest.RData, and because there was no
    > warning or error I quit without saving it
    > again. Oops. Massive Data Loss.

    >  Is there any reason why save(file="file.RData") couldn't
    > warn or error if you try and save nothing? There's no
    > obvious check in the R code for save.

    > Barry

    > PS the above scenario is fictional.
really?  ;-)

well, after *not* save()ing all your findings, it wouldn't have
been such a good day, would it?

well, in spite of that.
I agree that  save() should warn or stop in that case.
I have now committed a version -- to R-devel only -- 
which stop()s if  'pretest=TRUE' and uses  warning() otherwise,
e.g., in the case of save.image() when there's nothing to save.

Thank you, Barry. for the suggestion!
Martin

    > When did I last have a good day?

(I wish you more of those..)



[Rd] Saving nothing with save()
Martin Maechler