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

Mike R mike.rstat at gmail.com
Wed Jun 8 06:33:36 CEST 2005


On 6/7/05, Marc Schwartz <MSchwartz at mn.rr.com> wrote:
On 6/7/05, Gabor Grothendieck <ggrothendieck at gmail.com> wrote:
On 6/7/05, Liaw, Andy <andy_liaw at merck.com> wrote:
<snips>

Thanks Andy, Gabor and Marc.


---- contents of .Rprofile ----
.First <- function() {source("startup.r")}


---- contents of wrapR.v1 ----
#!/bin/bash
ln -s $1 startup.r
R
rm -f startup.r


---- contents of wrapR.v2 ----
#!/bin/bash
echo ".First <- function() {source(\"$1\")}" > .Rprofile
R

---- contents of project_A.r ----
library(graphics)
plot(1:10)


and then start R with either of the following command lines:
## ./wrapR.v1 project_A.r
## ./wrapR.v2 project_A.r


What do you think? is this the most simple way?

Thanks in advance,

Mike




More information about the R-help mailing list