This is an r-help question - please post to the relevant list next time.
The problem is with your "dev.off(dev.prev())" lines - you should
have used just "dev.off()" plain, without the dev.prev() inside.
As for why, please read the help pages.
Giampiero Salvi wrote:
> Hi,
> I am trying to produce
Hi,
I am trying to produce incremental plots directly using the pdf
device. I mean that I want to produce a plot, save it in a pdf
file, then add details and save the new plot in a new file, and
so on. Before I used to do this with x11, by just adding graphics to
a plot and then using dev.copy2eps