[R] How to detect if R is running on Mac OS X?

Prof Brian Ripley ripley at stats.ox.ac.uk
Mon Jan 15 10:39:39 CET 2007

I think there are two different questions here:

1) Is R running under darwin, the underlying OS of MacOS X?  You can test 
that by Sys.info or R.version$platform.  It seems unlikely that you would 
need this.   We do need to distinguish darwin at C level, as it is a very 
unusual 'unix', a much-modified version of FreeBSD.  One thing that
does show up at R level is the use of DYLD_LIBRARY_PATH rather than 

2) Is R runnng as part of the R.app GUI?  For that, test .Platform$GUI (it 
is I believe "AQUA" iff R.app is in use).

On Mon, 15 Jan 2007, Philippe Grosjean wrote:

> This question is probably trivial, but I don't find the answer. I have
> code that is different for Windows, Unix/Linux and Mac OSX. The man page
> of .Platform tells that .Platform$OS.type is the right way to test for
> it... but it also tels that it returns either "windows" or "unix". Is
> Mac OS X reported as "unix"? If yes, how do I make the difference?
> Thanks,
> Philippe Grosjean

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

More information about the R-help mailing list