I want to launch Rcmdr as a command from bash (or any unix shell), perhaps as an alias. R accepts the CMD argument and I could also pipe a script in with <. I would like the R console to stay open, and an interactive RCommander session to be started (Rcmdr is a popular GUI for R, for any newbies reading along, and it seems that you start up R, type library(Rcmdr) and then Commander() to start it up).
I am aware of how to add Rcmdr to my profile, and it appears to always start up if I include library(Rcmdr) in my .Rprofile, on my Linux workstation.
If I pipe my input in with < then this script works up to the point where it says that Commander GUI is launched only in interactive sessions:
R CMD BATCH ./rcommander.r
R --profile-custom ./.Rprofile2
Working on an Ubuntu machine here, I was able to use the advice provided by Dirk in this mailing list post:
nathan@nathan-laptop:~/tmp$ cat rcommander.r #!/bin/bash r -lRcmdr -e'while(TRUE) Commander();' nathan@nathan-laptop:~/tmp$ cat rcommander2.r #!/bin/bash Rscript --default-packages=Rcmdr -e 'while(TRUE) Commander();'
The first script uses Dirk's
littler package, available on CRAN, and the second uses the standard
Rscript executable. As noted, you can kill the process with
ctrl + c from your terminal.