Skip to content

Execute script and go interactive

2 messages · Michael Olschimke, Brian Ripley

#
Hi,

is it possible to execute a script with R and go into interactive mode
with the same session?

e.g.

R < myscript.R
Creating a .Rprofile is not an option for me.

Thank you

Michael
#
On Fri, 27 Feb 2009, Michael Olschimke wrote:

            
Yes, the mechanism is 'read the script file specified by 
R_PROFILE_USER (or its defaults) and then continue interactively'.

See ?Startup.
You need to explain why you are rejecting the mechanism provided to 
do this, and precisely what your constraints are.  Note that the 
locations of both R_PROFILE_USER and R_PROFILE_SITE are set by 
environment variables, so it would be very unusual not to be able to 
make use of them.

An R session is either interactive or it is not, and that is decided 
early in the startup process.  A session started by redirecting input 
is not (unless overridden by command-line flags), and it will never 
read normal input from anywhere other than stdin.  There is no 
equivalent of sink() for input.