Skip to content

Execute function at startup

1 message · Duncan Murdoch

#
As far as I know what you're asking for doesn't exist, so I've moved
this discussion to r-devel.

On Tue, 13 Apr 2004 16:22:37 +0200, Erich Neuwirth
<erich.neuwirth@univie.ac.at> wrote :
That looks as though you're creating an environment variable named
"runfist".  I'd rather use some different syntax than that...
That would be hard to implement, as most people start Rgui using a
shortcut, and shortcuts don't support I/O redirection.

However, I think it would be useful to be able to source a file
somehow.  I can see a couple of different possibilities:

Rgui --exec source('myfile.R')

or 

Rgui --source myfile.R

The semantics would be that the code is executed after all other
initialization is done (profile executed, user's saved image restored,
etc.), just as if it had been typed in the console.  When it's done,
control returns to the console (unless there's a q() in the commands).
Not now, but I think we should have something like this for 2.0.0.
There's already been some discussion about whether the bug fix to
.Profile is desirable (it's now run before most packages are
attached).  It makes sense to me to have a way of running code there,
and also to have a way to run code just before the system gives
control to the user.  

Duncan Murdoch