Assume you want to execute code in 'mycode.R', the easiest way is:

echo "source('mycode.R')" | R --vanilla --quiet

If you do it in a shell script, you can also pass variables to your code
like this (list of shell script):

#!/bin/sh
echo "var1=${1};var2=${2};source('mycode.R')" | R --vanilla -- quiet

Good luck,
Oleg


On 24/10/06, Grateful Frog <gratefulfrog@gmail.com> wrote:
>
> Hi!
>
> I've made great progress in my R programming, but I am again stuck on a
> beginner's problem.
>
> I would like to start R with a command line that loads a file, and if
> possible, executes a function.
>
> Can anyone  give me an example of how to do this?
>
> For example, in lisp, I would say:
>
> $ lisp -load toto.lisp -eval '(do-something $PORT)'
>
> to load the file "toto.lisp", then evaluate the expression with the shell
> envt variable bound properly.
>
> I'd like to do this in R, but can't figure it out!
>
> Thanks,
> GF.
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help@stat.math.ethz.ch 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.
>

	[[alternative HTML version deleted]]

