Jack BeNimble
Jack BeNimble

Reputation: 36663

interactive R startup script

I'm trying to run interactive R (Windows XP) with an input script that runs a few commands, and then leaves me at the R command line prompt. However, when I run it, it exits.

For example, here's the input file:

test.r: 
x = 1
x

Here's what happens when I run it with the input file as a parameter:

C:\>R --file test.t
>x = 1 
>x
[1] 1
C:\>  <--- exits and returns to prompt

Is there any way to run this without R exiting?

Upvotes: 3

Views: 692

Answers (1)

Dirk is no longer here
Dirk is no longer here

Reputation: 368251

I'd do it the other way around.

Just write a script that starts the normal R GUI or terminal application (per your choice), but then also place a file .Rprofile in the same directory which contains the code you want executed each and every time.

See help(Startup) on details about the files R looks up at startup and this may become clearer.

Upvotes: 3

Related Questions