If you want to do this interactively, you already have answers, but not for use with Rscript. To do this, you need to send messages to the console using cat :
If this test file is named "prompt.r" and is located in the directory where you are working in the system console session:
cat("a string please: "); a <- readLines("stdin",n=1); cat("You entered") str(a); cat( "\n" )
Then you can run it from the command line as
$ Rscript prompt.r
If you need a universal script, then it will run your script in interactive conditions and my script for non-interactive:
if (interactive() ){raw <- readline("TRUE or FALSE -- this is a validation run: ") if (raw == "F" | raw == "FALSE" | raw == "False"){ validation <- F } else{ validation <- T } rm(raw) } else{
source share