Here's another way to have different behaviour only for interactive sessions: if (interactive()) { winMenuAdd(menuname, NULL, NULL) # etc. }
>>> From: Duncan Murdoch <murd...@stats.uwo.ca> To:<jgar...@ija.csic.es> CC:<r-help@r-project.org> Date: 13/Feb/2010 6:15 a.m. Subject: Re: [R] Selective load of .First() function just for Rgui.exe On 12/02/2010 11:22 AM, jgar...@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 [[alternative HTML version deleted]] ______________________________________________ R-help@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.