[R] graphics - current filename

Thomas Lumley tlumley at u.washington.edu
Mon Feb 14 16:23:23 CET 2005


On Mon, 14 Feb 2005, Uwe Ligges wrote:

> Paul Sorenson wrote:
>
>> I would like to query R for the current (or last used) filename for a 
>> graphics device.
>> 
>> Eg after png(filename="plot%02d.png") I would like something like the 
>> output of dev.cur() but with the %02d expanded to the current name.
>
> You cannot, it is handled internally and the name is not returned.
> So you have to workaround yourself either by specifying filenames yourself 
> and looping over the png() calls, or counting yourself ...

Or just look on the disk with list.files().

   sort(list.files(pattern="plot[0-9][0-9]\\.png"),
                   decreasing=TRUE)[1]


 	-thomas




More information about the R-help mailing list