[R] R script autoload at startup

Prof Brian Ripley ripley at stats.ox.ac.uk
Mon Feb 27 15:31:59 CET 2006


On Mon, 27 Feb 2006, javier garcia-pintado wrote:

> Thank you very much Prof Brian R,
> I also wonder how I missed that.
> Anyway, In my .Rprofile file:
>> .First <- function() cat ("\n Welcome to R!\n")
> works perfectly, while:
>> .First <- function() winMenuAdd("Newmenu")
> give me the answer:
> "Error in .First(): couldn't find function "winMenuAdd"
> I just can add the new menu, and create the menu entries later, calling a source() that adds the menus.
> Perhaps the functions to add menus to the RGUI are called after the .RProfile is red?

> To add it via the .Rprofile would be perfect, but anywat, to be able to 
> create the menu calling manually a source after the GUI is completely 
> started is good enough for me.

You need to specify the package at that point, as when .First is run the 
default packages are not yet loaded (see ?Startup for the precise 
description).  E.g. (untested, as I am using Linux)

.First <- function() utils::winMenuAdd("Newmenu")


-- 
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