[R] warning on gamma option in par(args) or calling par(= new)?

AA aa2007r at gmail.com
Sat Dec 29 19:44:34 CET 2007


Thank you for your quick reply Prof. Ripley.
I thought I am modifying par() in par(mfrow = c(4,2)). This is not clear for 
me.
But I do understand now that par() applies to each device.
Thanks again.
AA.
----- Original Message ----- 
From: "Prof Brian Ripley" <ripley at stats.ox.ac.uk>
To: "AA" <aa2007r at gmail.com>
Cc: "'r-help'" <r-help at stat.math.ethz.ch>
Sent: Friday, December 28, 2007 3:09 AM
Subject: Re: [R] warning on gamma option in par(args) or calling par(= new)?


> You are calling par() *before* opening  and (in on.exit) *after* closing 
> the pdf() device.  par() applies on a per-device basis, and if no device 
> is open the default device will be opened.
>
> As for why you get the warnings about 'gamma' and 'new', see ?par and read 
> their entries.  Since you don't change any pars, I do not see why you are 
> attempting to reset them.
>
>
> On Thu, 27 Dec 2007, AA wrote:
>
>> 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 at 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.
>>
>
> -- 
> Brian D. Ripley,                  ripley at stats.ox.ac.uk
> Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
> University of Oxford,             Tel:  +44 1865 272861 (self)
> 1 South Parks Road,                     +44 1865 272866 (PA)
> Oxford OX1 3TG, UK                Fax:  +44 1865 272595



More information about the R-help mailing list