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

From: AA <aa2007r_at_gmail.com>
Date: Sat, 29 Dec 2007 13:44:34 -0500

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



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. Received on Sat 29 Dec 2007 - 18:47:02 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Sat 29 Dec 2007 - 21:30:20 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.