[R] Selective load of .First() function just for Rgui.exe

Duncan Murdoch murdoch at stats.uwo.ca
Fri Feb 12 18:13:27 CET 2010


On 12/02/2010 11:22 AM, jgarcia at ija.csic.es wrote:
> Hi all,
> I have a  .First <- function() {...} in the Rprofile.site file. Through
> .First() I'm adding several menus to the GUI to access several functions
> I've been developing for own use.
> 
> However, I also need to launch R scripts silently in a batch way, and
> in this case I get the error message:
> 
> "Error in winMenuAdd(menuname, NULL, NULL):
>  Menu functions can only be used in the GUI"
> 
> Do you know about about a way to selectively read the .First()
> function just for Rgui.exe, but not for call to R.exe?

The .Platform variable contains a list of things that identify the 
current platform.  In Rterm (or R.exe) you'll have .Platform$GUI == 
"RTerm", whereas in Rgui, it will be "Rgui".

Duncan Murdoch



More information about the R-help mailing list