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. Can anyone point me at where I can find this please?
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 ... Uwe Ligges> Can anyone point me at where I can find this please? > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
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