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

Loren Engrav engrav at u.washington.edu
Wed May 6 18:02:17 CEST 2009

Hi and thank you

Why d&d directory onto R.app?

Now that I understand the common use of many Rdata's, one in each working
folder, and Pref notes say "d&d of file or directory on R icon will
override", I was trying to get with common usage by starting up with d&d
onto R.app rather then double clicking R.app and then changing location; did
not try to d&d a file since the R files (Rhistory and Rdata) are invisible;
and then found that the "Always apply" directory is overridden; so then
confused about what does "Always apply" mean

This is part of my "prefs are confusing" problem but not part of the
"Rhistory commands being forgotten" problem; which is probably more

Today I said I would stop fiddling with Rhistory and do work, but I find if
I double click on the bottom entry in the history window, things go wrong.
Seems like returns are added and multiple commands are combined into one
entry in the file. Here is what the end of the history file looks like in

rm (ABeset_gcrmaNumhom)
AB_gcrmaNumhom <- gcrma(AA_ReadAffyNumhom, fast = FALSE)






> From: Rob Goedman <robjgoedman at me.com>
> Date: Wed, 06 May 2009 08:02:29 -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,
> I will look into the 'Always apply', your understanding is correct and
> it should not change the working directory on drag&drop of a file or a
> directory if 'Always apply' is selected (according to my own note :-).
> It seems to work fine for a file but not for a directory.
> Simon, do you recall if there was a specific reason why we treated
> files and directories similar? What's the point of d&d-ing a directory
> on the R.app icon other than to set the working dir?
> Loren, why do you d&d a dir on R.app?
> A quick test with 'R-in-a-terminal' indeed does show R creates a
> history file after answering the q() question with yes. Not sure if
> that is R or maybe some initial default behavior. Of course, in a
> terminal the file actually contains history commands. I fully agree
> with Simon, deviating from R haunts you for many years (but at that
> time of making those changes I did not want to drop the old R.app
> multi-line history feature).
> Rob
> On May 6, 2009, at 7:10 AM, Loren Engrav wrote:
>> No no, thank you for helping
>> To clarify, I am not out to "fix" or "change" anything, or report
>> bugs, I
>> just want to understand how to efficiently use R.app, my problems are
>> 1-on my systems (one 32 and one 64), Rhistory "forgets" commands
>> which is
>> how this all started, and
>> 2-I find the Startup Preferences confusing
>> Ok, Rdata: several explained that in the workspace, a new object "x"
>> will
>> overwrite an old object "x" without warning, by keeping Rdata's
>> separate one
>> can use "x" many times for different things, I have always manually
>> saved
>> important Rdata's and ignored the default Rdata, but I can change,
>> or do
>> both now that I understand
>> Now Directory in Preferences: I have checked Always apply and the
>> directory
>> is ~; the notes say dd of directory will override if not enforced;
>> but if I
>> dd a folder onto R, the working directory is not ~ but rather the
>> one dd'd
>> onto R, so does not seem "Always apply" is working
>> Now Rhistory: again the problem is Rhistory forgets commands on my
>> system,
>> which is why I got into this, but then I find Rhistory(s) all over
>> in Prefs I have checked Read on startup and the history file is
>> ~/.Rhistory
>> (return saves that value, thank you again, this might be in the
>> notes) and I
>> checked Cleanup history.
>> It appears that if I work in some directory and then quit w save, the
>> history is written to both ~/.Rhistory and the directory. So I had 33
>> .Rhistory(s) on the drive even tho I told R.app to use one.
>> So I tried your second idea, changed the R.app history name
>> to .xxxRhistory
>> and voila, ".xxxRhistory" appears where R.app Preferences say and
>> ".Rhistory" appears in the working directory, so would appear you are
>> correct; R.app is writing out .xxxRhistory and somebody else is
>> writing
>> .Rhistory
>> Now if I work in the default directory AND have R.app set to write
>> .xxxRhistory AND quit/save, I again find in the directory
>> both .xxxRhistory
>> and .Rhistory, so you are again correct; R.app writes .xxxRhistory and
>> somebody else writes .Rhistory
>> And the .Rhistory file is written about 4 sec after the .xxxRhistory
>> file
>> and the .Rhistory file is 0kb
>> So then your third idea might be correct; ie if R.app
>> writes .Rhistory it is
>> overwritten by the second writing of .Rhistory and if the
>> second .Rhistory
>> is missing commands, then it would appear that R.app is forgetting
>> commands
>> In sum
>> 1-is it possible that .Rhistory from R overwrites .Rhistory from
>> R.app and
>> the history that R uses is incomplete so commands are "forgotten"
>> 2-and of course what is the work around for #2
>> 3-and lesser, what does "Always apply" do for the directory
>>> From: Rob Goedman <robjgoedman at me.com>
>>> Date: Tue, 05 May 2009 21:34:16 -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,
>>> 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