Skip to content
Prev 199728 / 398502 Next

Command-line arguments and --interactive

Adam D. I. Kramer wrote:
--interactive tells R that there is a human producing the input stream, 
so it can ask questions and expect them to be answered.  In your 
experiments with it, your input stream was the pipe holding the output 
of echo, and R got confused because that pipe wouldn't answer its question.

Your problem is that you want an input stream that starts out from your 
fixed code and then switches to your shell's stdin.  I think you can do 
that on some systems
by saving your input to a file then concatenating it to stdin, e.g. 
something like this:

echo '10*5; scan()' >test.R
cat test.R - | R --interactive

I don't know if there's a way to do this in one line, and I'd expect 
some oddities.

Duncan Murdoch