[R] force or "assert interactive use" with the --ess parameter in Windows

Duncan Murdoch murdoch.duncan at gmail.com
Thu Jul 15 12:54:49 CEST 2010


On 15/07/2010 4:33 AM, Daniel Sachse wrote:
> That is quite sad.
> 
> On 15.07.2010 10:12, Allan Engelhardt wrote:
>> On 14/07/10 09:37, Daniel Sachse wrote:
>>> [...]
>>>
>>> I am seriously confused. Is there no such thing as
>>>
>>> "R --persist MyScript.R myarg1 myarg2"
>>>
>>> that would run MyScript interactively?
>> In a word: no.
>>
>> Depending on what you are really trying to do, you may find source() 
>> useful from within a R session.
>>
>> Allan
> 
> I even got far enough as to get R to execute a command and stay 
> interactive with
> 
> C:\...\bin>echo print(interactive()) | R --ess --slave
> [1] TRUE
> 
> So, in the same way I could also start sourcing an arbitrary .R-file 
> right from the command line.
> 
> However, R still terminates the session after running the command piped 
>   to it.
> 
> Do I really have to launch R and then manually type s-o-u-r-c-e- etc. in 
> order to start my programs?

I don't know how to do this in Windows cmd, but if you're running a bash 
shell (e.g. from Cygwin) this appears to work:

  (echo print\(interactive\(\)\); cat ) | Rterm --ess

Duncan Murdoch



More information about the R-help mailing list