[R] RGui: windows-record and command history

Peter Ehlers ehlers at math.ucalgary.ca
Fri Mar 24 02:43:35 CET 2006


Thanks, Paul, that's useful information.

Peter

Paul Murrell wrote:
> Hi
> 
> 
> Peter Ehlers wrote:
> 
>>
>>Paul Murrell wrote:
>>
>>
>>>Hi
>>>
>>>
>>>Duncan Murdoch wrote:
>>>
>>>
>>>>On 3/23/2006 10:46 AM, Gabor Grothendieck wrote:
>>>>
>>>>
>>>>
>>>>>On 3/23/06, Duncan Murdoch <murdoch at stats.uwo.ca> wrote:
>>>>>
>>>>>
>>>>>
>>>>>>On 3/23/2006 10:29 AM, Gabor Grothendieck wrote:
>>>>>>
>>>>>>
>>>>>>
>>>>>>>On 3/23/06, Duncan Murdoch <murdoch at stats.uwo.ca> wrote:
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>>On 3/23/2006 7:35 AM, Thomas Steiner wrote:
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>>a) How can I set the recording of all windows()-history forever to
>>>>>>>>>"true"? I want something like windows(record = TRUE) but not 
>>>>>>>>>just for
>>>>>>>>>the window that opens then, but for all windows I will open ever.
>>>>>>>>
>>>>>>>>
>>>>>>>>options(graphics.record=TRUE)
>>>>>>>>
>>>>>>>>will make that happen for the rest of the session.  To really 
>>>>>>>>make it
>>>>>>>>happen forever, you need to put this line in your Rprofile (see
>>>>>>>>?Rprofile for where that comes from).
>>>>>>>>
>>>>>>>>Watch out though:  the graphics history is stored in your current
>>>>>>>>workspace in memory, and it can get big.  You might find you're 
>>>>>>>>running
>>>>>>>>out of memory if you store everything, and you'll find your 
>>>>>>>>.RData files
>>>>>>>>quite large if you save your workspace.
>>>>>>>>
>>>>>>>>On my todo list (but not for 2.3.0) is the possibility of setting a
>>>>>>>>default history length, perhaps defaulting to saving the last 2 or 3
>>>>>>>>pages.
>>>>>>>
>>>>>>>
>>>>>>>Would it be feasible to have history on disk or perhaps the last
>>>>>>>m in memory and the last n (possibly Inf) on disk?
>>>>>>
>>>>>>
>>>>>>The history is just another R object.  Saving big R objects on disk
>>>>>>might be desirable, but it would be a big change, so I'd call it
>>>>>>infeasible.  I wouldn't want to get into special-casing this 
>>>>>>particular
>>>>>>R object:  that way lies madness.
>>>>>>
>>>>>>However, since it is just an R object, it's available for R code to 
>>>>>>work
>>>>>>with, so someone who was interested in doing this could write a
>>>>>>contributed package that did it.
>>>>>
>>>>>
>>>>>Are there R-level facilities to manipulate the history, not
>>>>>just the top?
>>>>
>>>>
>>>>
>>>>Sure, it's a regular R object. You will need to read the source to 
>>>>know how to interpret it, and since it's undocumented there's a risk 
>>>>of changes in future R versions, but it's not very complicated.  See 
>>>>my message to Peter.
>>>
>>>
>>>
>>>
>>>Be careful with this.  The objects that are recorded on the display 
>>>list are calls to graphics functions PLUS state information in a raw 
>>>binary format.  The display list was originally intended for reuse 
>>>within the same R session (for redrawing the screen).  If you try to 
>>>save it and use it between sessions or (worse) between versions of R 
>>>you could run into some nasty problems.  For example, what if the 
>>>graphics function interface has changed?  what if the raw binary state 
>>>information format has changed?  what if the required packages are not 
>>>installed?   At best, your saved object produces errors;  at worst it 
>>>becomes completely useless and is unrecoverable.
>>>
>>>Paul
>>
>>
>>Paul,
>>If I read your comments correctly, the problem with manipulating the
>>graph history is with saved histories across sessions/versions. Is
>>there any reason not to manipulate it *within* a session? I never
>>save plots for re-use in R. Re-running code is usually best for me.
>>But I would find it handy to fiddle with the display list in a
>>session.
> 
> 
> 
> That is *one* problem with the display list.  Messing directly with the 
> display list *within a session* is *less* dangerous, but R's behaviour 
> if you do that is "undefined".
> 
> The display list is technically an internal structure for R's internal 
> use.  We can't stop you playing with it, but I do not encourage it and 
> it is not officially supported.
> 
> There are a number of simple things that you could do to the display 
> list that should work, but providing proper support for general 
> manipulations of the display list would require a significant amount of 
> (re)design of the R graphics code.
> 
> Paul
> 
> p.s.  These comments apply to the display list in R's "graphics engine". 
>   The 'grid' package also maintains a display list, and that has been 
> designed to support more general manipulations.




More information about the R-help mailing list