1

I have an R script file `foobar.R'. I want to run the script, and then leave me in the interactive R session when it's done.

Calling

$ Rscript foobar.R

or

$ R -e "$(cat foobar.R)"

does not provide the desired behaviour, since the R interpreter immediately quits when the script is done.

Currently, I am using

$ R
> source("foobar.R")

The problem is that the second command needs to be typed inside the R interpreter - I would like to do it all in a single line form the shell, so that I can set an alias for it, or simply recall a previous command with the up-arrow.

In essence, I am looking for something like Python's

$ python -i foobar.py

Does such an option exist for R?

Drubbels
  • 211

0 Answers0