[R] How to execute an expression as well as a .R file with Rscript?
thmsfuller066 at gmail.com
thmsfuller066 at gmail.com
Thu Aug 19 23:30:10 CEST 2010
Hello All,
I'm trying to supply both an expression and a .R file to Rscript. But
it seems that it is not possible with the first approach (see below)
and I'll have to use the second approach (see below). I'm wondering if
it is a bug in Rscript not to support both a .R file and an
expression.
$ cat main.R
x=x+3
print(x)
$ cat main.sh
#!/usr/bin/env bash
Rscript -e 'x=10' main.R #first approach
Rscript -e "x=10; source('main.R')" #second approach
$ ./main.sh
> x=10
>
>
> x=10; source('main.R')
[1] 13
>
>
--
Tom
More information about the R-help
mailing list