[R-SIG-Mac] R.app history forgets

Rob Goedman robjgoedman at me.com
Wed May 6 06:34:16 CEST 2009


Loren,

Please find my comments inserted below. Thank you for being persistent!

On May 5, 2009, at 4:13 PM, Loren Engrav wrote:

> Ok, so Rdata goes to the directory one is working in; and so will have
> Rdata's in many folders which seems strange

As a counter example, I work on 5 or 6 different projects  
simultaneously,
each in its own directory sub tree. Several of the projects need to  
store the
workspace after I'm done. This is implemented as the default mechanism.

Through the .Last mechanism you can get your desired behavior. But
unfortunately, it will take some extra work to define the .Last  
function.
That should take care of many .RData's.

> As for Rhistory if one declines to save workspace, Rhistory is  
> written to
> the directory specified; if one saves workspace Rhistory is written  
> to both
> the directory specified and the workspace directory, ie to both;  
> this also
> seems strange.

Could it be R, not R.app that creates the .Rhistory file if the  
workspace is
saved????? I am not aware of this behavior (the fact that R creates a
history file when asked to save the workspace), or simply might have
missed it if it was introduced in the 4 or 5 years since I worked on the
history mechanism for R.app.

> And the troubled history is attached
>
> This seems problematic; not knowing where these files are going and  
> winding
> up with many; and then the forgetful Rhistory as well

And indeed, in that case, if the name of the history file set in the  
R.app
preferences is the same as R's default name (.Rhistory) ***and*** the
workspace is saved, the history file seems to forget recent commands
because R.app writes its history file which is subsequently overwitten  
by R.

Maybe someone familiar with the R source can confirm this behavior, I  
have
rarely looked at the R source, just at the R.app code.

Rob




> Thank you
>
>
>> From: Rob Goedman <robjgoedman at me.com>
>> Date: Tue, 05 May 2009 12:20:51 -0700
>> To: Loren Engrav <engrav at u.washington.edu>
>> Cc: "r-sig-mac at stat.math.ethz.ch" <r-sig-mac at stat.math.ethz.ch>
>> Subject: Re: [R-SIG-Mac] R.app history forgets
>>
>> Loren,
>>
>> Thanks for the screen shot.
>>
>> A bit more experimentation and a quick look at the code refreshed my
>> memory.
>>
>> If you exit R, .RData is always written to the directory you are in.
>>
>> In your setting, on q() to quit, R.app should ask for conformation to
>> save the workspace.
>>
>> If you don't change your directory it should create a .RData in your
>> home directory (that's where your R.app started).
>>
>> Preferences do not provide help here, but you could create a .Last
>> function with a save.image() command in it to force storing  
>> the .RData
>> file to a fixed directory. In that case you can opt to set the Quit
>> preferences to 'No' (don't ask me to store the workspace).
>>
>> For history its a (tiny) bit more flexible. By selecting an absolute
>> path, like you have in your setting, it will always store the current
>> available history commands in that file (including the ones that were
>> read in during startup, so the new commands are at the end of the  
>> file).
>>
>> If this does not work for you, can you send me your ~/.Rhistory file
>> after executing a last new command in R.app, maybe something like
>> 'testHist <- 1' and quitting R.app?
>>
>> As you found in the archives, a few folks did have trouble (usually
>> because R.app could not write to the selected directory).
>>
>> After this email it might be better to take this discussion off-line.
>>
>> Regards,
>> Rob
>>
>>
>> On May 5, 2009, at 11:50 AM, Loren Engrav wrote:
>>
>>> Thank you
>>> attached
>>>
>>>
>>>> From: Rob Goedman <robjgoedman at me.com>
>>>> Date: Tue, 05 May 2009 11:36:25 -0700
>>>> To: Loren Engrav <engrav at u.washington.edu>
>>>> Cc: "r-sig-mac at stat.math.ethz.ch" <r-sig-mac at stat.math.ethz.ch>
>>>> Subject: Re: [R-SIG-Mac] R.app history forgets
>>>>
>>>> Loren,
>>>>
>>>> Can you send me a screen copy of the Startup preferences ( with the
>>>> cursor inside the Startup Preferences window, press Command- 
>>>> Shift-4,
>>>> followed by pressing the spacebar, followed by a click of the mouse
>>>> button, this should write it to your Deskop as 'Picture 1').
>>>>
>>>> Rob
>>>>
>>>> On May 5, 2009, at 11:24 AM, Loren Engrav wrote:
>>>>
>>>>> Mac OS 10.5.5 and R.app 2.9.0
>>>>>
>>>>> I start up, run a few things, and quit (w or wo save) and no
>>>>> directory
>>>>> changes
>>>>>
>>>>> Then I restart and the recent commands are no longer in Rhistory
>>>>>
>>>>> The only box I have checked in History preferences is Read on
>>>>> Startup and I
>>>>> have max entries set to 5000
>>>>>
>>>>> I see queries about this before but I could find no solution
>>>>>
>>>>> Thank you
>>>>>
>>>>> [[alternative HTML version deleted]]
>>>>>
>>>>> _______________________________________________
>>>>> R-SIG-Mac mailing list
>>>>> R-SIG-Mac at stat.math.ethz.ch
>>>>> https://stat.ethz.ch/mailman/listinfo/r-sig-mac
>>>>
>>>
>>> <Picture 3.png>
>>
>> On May 5, 2009, at 9:37 AM, Loren Engrav wrote:
>>
>>> Thank you
>>> The return before clicking anywhere else solved that problem, clever
>>>
>>> So I trash all invisible .Rhistory and .Rdata files
>>> Then made a new folder (called R_History_Data) and aim Preferences
>>> at this
>>> folder (using the return)
>>> Then run R.app and yes, I have one .Rhistory and one .Rdata in that
>>> folder
>>>
>>> But then I change the working directory and do some stuff
>>> Then quit and save working directory
>>> And now I have two of each invisible files, one in R_History_Data
>>> and one in
>>> the working directory folder
>>>
>>> So it still appears as I move from directory to directory I will  
>>> leave
>>> invisible .Rhistory and .Rdata files all over
>>>
>>> Is it possible to have Rhistory and Rdata always written to the
>>> R_History_Data folder?
>
> <TroubledHistory.history>



More information about the R-SIG-Mac mailing list