Brian G. Peterson Brian G. Peterson - 1 year ago 95
R Question

detecting operating system in R (e.g. for adaptive .Rprofile files)

I was wondering how to automatically detect operating system in R, for example to place things in the .Rprofile.

Answer Source

I'm not sure about using since the help page says it is not implemented on all R platforms; maybe use .Platform instead? ?.Platform has a lot of useful information, since:

‘.Platform’ is a list with some details of the platform under which R was built. This provides means to write OS-portable R code.

It also seems the packages included with R use .Platform much more frequently than

josh: /c/R/R-2.12.0-src/src/library
> grep ".Platform" */R/* | wc -l
josh: /c/R/R-2.12.0-src/src/library
> grep ".Platform\$OS.type" */R/* | wc -l
josh: /c/R/R-2.12.0-src/src/library
> grep "" */R/* | wc -l
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download