You could override par by optionally passing it as an argument:

f <- function(x = 1:10, y = 1:10, par = list(mfrow = c(2,2))) {
        if (!is.null(par)) {
                on.exit(par(opar))
                opar <- par(par)
        }
        plot(x)
        plot(y)
}

opar <- par(mfrow=c(4,4))
for(i in 1:8) f(par = NULL)
par(opar)



On 5/15/06, [EMAIL PROTECTED]
<[EMAIL PROTECTED]> wrote:
> Dear all,
> I have the following problem:
> I have written a function genereating to plots, eg
> myfunction <- (data, some.parameters) {
>        #some calculations etc
>        .
>        par (mfrow=c(1,2))
>        plot1(......)
>        plot2(.....)
> }
> which works fine. But for analysing several variants, I tried a slope, eg:
>
> par (mfrow=c(5,5))
>  for ( i in 1:10) {
>    myfunction(data, i)
> }
>
> Off course, the par() in myfunction overwrites the par() before the slope. 
> So, how to write myfunction, that it plots two plots and can be used in the 
> slope like in the example?
>
> Thanks a lot, Dirk
>
> Dr.med Dirk Weismann
> Schwerpunkt für Endokrinologie und Diabetologie
> Medizinische Universitätsklinik I
> 97080 Würzburg
> email: [EMAIL PROTECTED]
> Telefon: 0049-931-201-36744
>
>        [[alternative HTML version deleted]]
>
>
>
> ______________________________________________
> [email protected] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>
>

______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

Reply via email to