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
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?At least the R GUI reports .Platform$OS.type as "unix" on Mac OS X. Sys.info() gives some additional information: > Sys.info()["sysname"] sysname "Darwin" Note that not all Darwins are necessarily Mac OS X. The R GUI has .Platform$GUI = "AQUA", which I believe is unique to Mac platform. Then again, I have no idea what R installed from sources, MacPorts or Fink reports. The GUI is probably different. Also note that the Mac OS 10.4 has BSD inside by default, so you may get away with the same code for Unix/Linux and Mac. HTH, Jarimatti Valkonen
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 LD_LIBRARY_PATH. 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