[R] how to run a script at the beginning of an interacive session ?

Marc Schwartz MSchwartz at mn.rr.com
Thu Jun 9 00:41:08 CEST 2005


On Wed, 2005-06-08 at 11:32 -0700, Mike R wrote:
> On 6/8/05, Marc Schwartz <MSchwartz at mn.rr.com> wrote:
> <snips>
> 
> Thanks Marc,
> 
> Cool ideas, thanks!  Building on them, here is a twist. 
> 
> With this line in .Rprofile:
> 
>   .First <- function() {if(Sys.getenv("R_PROJECT")!="")
> source(Sys.getenv("R_PROJECT"))}
> 
> R can be run with this bash command line:
> 
> ##  export R_PROJECT=project_A.R;  R; unset R_PROJECT
> 
> 
> Alternatively, R could be run with this bash command line:
> 
> ##  wrapR project_4.R
> 
> ---- contents of wrapR ----
> #! /bin/bash
> export R_PROJECT=$1
> R 
> ---- end ----
> 
> What do you think? 
> 
> Thanks in advance,
> Mike
> 

Mike,

At this point, I think whatever approach to implementing and managing
the process you might find easier is the way to go. Whether it be the
above or my approach.

The initial iteration resulted in overwriting the default ~/.Rprofile
file, which could cause problems if you had other options/settings in
it.

The key is ease of implementation, reduction in conflicts/errors and
ongoing maintenance if you find yourself needing multiple startup
options.

HTH,

Marc




More information about the R-help mailing list