You can use back-ticks (`) in most shells to capture output. So print
the value you want using R's cat() function, and capture it thus:
$ cat test.R
string <- 'TEST'
cat(string)
$ v=`R --slave --no-save < test.R `
$ echo $v
TEST
bash shell also allows $( ) notation:
$ v=$(R --slave --no-save < test.R )
note the use of --slave to make R shut up about itself.
没有评论:
发表评论