Skip to content
Back to formatted view

Raw Message

Message-ID: <50FD0011.6070401@stats.ox.ac.uk>
Date: 2013-01-21T08:45:05Z
From: Brian Ripley
Subject: How to check if R.app is running?
In-Reply-To: <50FC699B.2040102@gmail.com>

On 20/01/2013 22:03, Duncan Murdoch wrote:
> On 13-01-20 4:51 PM, Nick Matzke wrote:
>> 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.
>>
>>
>
> .Platform$GUI will be different in the two cases:  "AQUA" for R.app and
> something else in other cases.  I don't know if that's a good test to
> find out if clusterApply is safe.

No, as clusterApply does not use multicore nor forking, and runs workers 
via Rscript.

The multicore functions in parallel are protected in R.app in current 
versions of R, at least.

There seems a lot of misinformation about.

>
> Duncan Murdoch
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.


-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595