[R] RGui: windows-record and command history

Duncan Murdoch murdoch at stats.uwo.ca
Thu Mar 23 18:36:03 CET 2006


On 3/23/2006 10:34 AM, Peter Ehlers wrote:
> Duncan Murdoch 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.
> [snip]
> 
> Duncan,
> 
> This may be asking too much, but would it be possible to consider
> implementing selective graph removal from the graph history?
> I use graph.record=TRUE frequently for comparing graphs, but often
> find that I'd like to kill one of the graphs while keeping others
> in memory.

That's probably not too hard to do in R code.  You just need to look at 
the source in src/library/grDevices/R/windows/windows.R for the 
print.SavedPlots method, and maybe the C level code in 
src/library/grDevices/src/devWindows.c for a bit more help on the 
interpretation of the .SavedPlots object, and then it should be fairly 
straightforward to write a function that deletes an entry in the 
history.  (It's a list with 5 components, the first 4 of which describe 
the current state and what the user is looking at, and the last of which 
is a list containing the actual recorded plots.)

Duncan Murdoch




More information about the R-help mailing list