[R] Q: calling par() in .First()

Thomas Lumley tlumley at u.washington.edu
Fri Aug 3 01:25:54 CEST 2007


On Thu, 2 Aug 2007, D. R. Evans wrote:

> As a result of another thread here, I need to be sure that the
> function par(bg='white') has executed before I create a plot. The
> simplest thing seemed to put it in .Rprofile:
>
> .First <- function() {
>  options(width=150)
>  par(bg='white')
> }
>
> But now R complains at startup:
>  Error in .First() : couldn't find function "par"
>
> I have confirmed that once R has started, I can type "par(bg='white')"
> and R no longer complains.
>
> ISwR has a nice little section on "Using par", but there's no hint
> that something like this can go wrong :-(
>
> So what am I not understanding this time?

par() is in the 'graphics' package, which is not loaded by the time .Rprofile runs.  You want
    graphics::par(bg='white')

Information from which this can be deduced and examples are in ?Startup, though it isn't explicitly stated there.

      -thomas

Thomas Lumley			Assoc. Professor, Biostatistics
tlumley at u.washington.edu	University of Washington, Seattle



More information about the R-help mailing list