[R] Is there some way to append to a pdf after its device has been closed?

Sarah Goslee sarah.goslee at gmail.com
Tue Dec 30 17:29:11 CET 2008


Is there some reason you can't reverse the loops? Then you'd have
only one device open at a time.

for ( i in length(obj.list) ) {
     dev.set( device.list( j ) )
     for( j in iters) {
         # do plotting and other stuff for this list member
    }
     # close current device
 }


Sarah

On Tue, Dec 30, 2008 at 11:21 AM, Alex Pine <alex.pine at nyu.edu> wrote:
> Patrick,
>
> The reason I'm having a problem is because R only allows a maximum of 64
> devices to be open at one time. If it allowed more than that, I wouldn't
> have a problem. One way to get around that problem would be if I could close
> a device and then append to it later, but there doesn't seem to be a way to
> do that. My code works something like the following:
>
> iters <- 1:100
> obj.list <- ( long list of complex objects, of which there are > 64 )
> device.list <- (holds a reference to all postscript devices, one for each
> object in obj.list)
>
> for ( i in iters ) {
>   for( j in length(obj.list) ) {
>      dev.set( device.list( j ) )
>      # do plotting and other stuff for this list member to the j-th file,
> appending to what has
>      # been plotted before now
>   }
> }
> # close all devices
>
> This code fails because I cannot have more than 64 devices at a time. If it
> were possible, every time the inner loop is executed, to set the current
> device to the one corresponding to that list member, append to the (possibly
> non-empty) postscript file and then close the device at the end of the inner
> loop, my problem would be solved. Can you figure out a way to do this?
>
> Thanks,
>
> Alex
>
-- 
Sarah Goslee
http://www.functionaldiversity.org



More information about the R-help mailing list