Skip to content
Prev 315701 / 398506 Next

How to check if R.app is running?

Hi, here's an obscure question someone can hopefully help with.

I have some R code that uses stuff from parallel (now a part 
of the R core in 2.15 I believe), especially clusterApply. 
However, this seems to cause problems in R.app, and I've 
seen advice to not use these multicore functions, e.g. doMC, 
in R.app.

So, I want to make this optional.  How can have a program 
check whether or not it is running in R.app or regular R?

Thanks so much for your help!!
Nick

PS: I saw this:
http://stackoverflow.com/questions/2020790/r-script-determine-whether-the-script-is-run-in-the-gui-or-from-command-line

Which says to use:

interactive()

...but that doesn't work.  Interactive R is fine (e.g. 
starting R from Mac Terminal), only R.app is not.