Skip to content
Prev 38604 / 63424 Next

Wait for user input with readline()

On Dec 7, 2010, at 12:19 PM, Petr Savicky wrote:

            
You can't tell R code and input apart in cases like
R < myScript.R
but you can if you use source() or Rscript -- and you can treat them differently.

I assume what Alexandre wants is something like:
input=file("stdin")
print(readLines(input,1))
which works both in interactive and non-interactive setting and expects input in both cases (if you use Rscript or R -e 'source("...")' ).

Cheers,
Simon