[R] device error pdf
    Christian Hoffmann 
    c-w.hoffmann at sunrise.ch
       
    Mon Oct  8 15:39:31 CEST 2012
    
    
  
Hi,
Iwrote 'pdfc' in analogy to 'lpr':
pdfc <- function (file = "Rplot.pdf") {
   current.device <- dev.cur()
   dev.off(dev.copy(device = pdf, file = file, ...))
   dev.set(current.device)
   print(paste(file, "generated."))
   }
lpr <- function (object, file = "Rplotlpr.ps", ...)
{
     if (missing(object)) {
         current.device <- dev.cur()
         dev.off(dev.copy(device = postscript, file = file, ...))
         dev.set(current.device)
         system(paste("lpr", file))
         print(paste(file, "printed."))
     }
     else {
         if (missing(file))
             file <- "Robjlpr.txt"
         sink(file)
         object <- as.character(substitute(object))
         print(get(object))
         sink()
         system(paste("lpr", file))
         print(paste(object, "printed."))
     }
}
Now, while
  
> lpr()
[1] "Rplotlpr.ps printed."
is working almost fine (the plot window of Quartz-2 is not sized correctly, what would you suggest, Ray Brownrig \email{ray at mcs.vuw.ac.nz} ?),
with > pdfc()
I get
Error in dev.off(dev.copy(device = pdf, file = file, ...)) :
   '...' used in an incorrect context
I searched the Web, but found no hint how to avoid  this error. So the culprit could be
device = pdf
On the other hand  executing
> pdf()
generates the file
Rplotlpr.ps
but this very small and causes the Adobe Reader to say
This file is damaged and cannot be opened.
Thanks for help.
Chirsitan HOffmann
-- 
Christian W. Hoffmann,
CH - 8915 Hausen am Albis, Switzerland
Rigiblickstrasse 15 b, Tel.+41-44-7640853
c-w.hoffmann at sunrise.ch,
christian at echoffmann.ch,
www.echoffmann.ch
    
    
More information about the R-help
mailing list