Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

interactive R startup script

Tags:

r

statistics

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?

like image 262
Jack BeNimble Avatar asked Aug 22 '26 02:08

Jack BeNimble


1 Answers

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.

like image 182
Dirk Eddelbuettel Avatar answered Aug 23 '26 21:08

Dirk Eddelbuettel