Dear All,

I have the following function

tstpar <-
  function(n = 200, want.pdf = FALSE, pdfFileName = NULL){
    oldpar <- par(no.readonly = TRUE)
    on.exit(par(oldpar))
    steps  <- seq(from = 1, to = 8, by = 1)
    h <- 10; w <- 6
    if(want.pdf){pdf(file = pdfFileName, onefile = TRUE,
    paper = "letter", width = w, height = h)}
    par(mfrow = c(4,2))
    for(i in steps){
      txt <- paste("i = ", i)
      hist(rnorm(n), main = txt)
    }
    if(want.pdf){dev.off()}
  }

when called with default values tstpar() every thing works fine.
However I get 2 sorts of warnings
1- if I call the function to generate a pdf as
   tstpar(want.pdf = TRUE, pdfFilename = "jj.pdf")
   I get the following warning msg:
   calling par(new=) with no plot in: par(oldpar)
   with an empty device which I don not understand since I close
   the device in the function.
2- If I comment the line 
   if (want.pdf){dev.off()}
   I get the following warning
   'gamma' cannot be modified on this device in: par(args)
   with 2 empty devices. 
  
I do not understand why I get those warnings and why I get those empty devices.
I looked up in RSiteSearch and I found the 2 following posts
http://finzi.psych.upenn.edu/R/Rhelp02a/archive/38553.html
In this post M. Schwarz explains that there is not a plot created that's why R 
generates the 
warning. In the case of tstpar, I generate the hist plots and should not be 
getting the warning.

And in the following post Prof Ripley refers to an old R warning for pdf() 
devices
Which is not the case here.
http://finzi.psych.upenn.edu/R/Rhelp02a/archive/23215.html 

I do not see what I am missing. Thanks for any hint.
I use R 2.5.1 under Win XP.
I apologize if the question is related to my older R version which I will 
upgrade.

AA.

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to