[R] How to detect if R is running on Mac OS X?
Jarimatti Valkonen
javalkon at hytti.uku.fi
Mon Jan 15 09:20:19 CET 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?
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
More information about the R-help
mailing list