51

Possible Duplicates:
detecting operating system in R (e.g. for adaptive .Rprofile files)
How can I determine in R what platform I'm running on?

Is there a primitive function in R that will return information about the system on which R is running? I am concerned primarily with the OS, but any other data could be helpful.

MichaelChirico
  • 33,841
  • 14
  • 113
  • 198
gappy
  • 10,095
  • 14
  • 54
  • 73
  • 2
    Looks like duplicate [detecting operating system in R (e.g. for adaptive .Rprofile files)](http://stackoverflow.com/questions/4463087/detecting-operating-system-in-r-e-g-for-adaptive-rprofile-files) – Marek Jan 20 '11 at 13:40
  • 1
    And this one: http://stackoverflow.com/questions/3919621/how-can-i-determine-in-r-what-platform-im-running-on/3922058#3922058 – Gavin Simpson Jan 20 '11 at 13:50

2 Answers2

63

use Sys.info() for all information about the system, Sys.info()['sysname'] gives you the OS.

R.Version() gives you the version of R, including which architecture you're running (32bit - i386 - versus 64bit - x64 - ).

R.home() and system.file(package="xxx") give you information of the location of the root resp. the package files.

Joris Meys
  • 106,551
  • 31
  • 221
  • 263
49

Here are three ways:

> .Platform$OS.type
[1] "unix"
> version$os ## or R.version$os
[1] "linux-gnu"
> Sys.info()["sysname"]
sysname 
"Linux"

Take a look at ?Sys.info for some details and provisos.

Gavin Simpson
  • 170,508
  • 25
  • 396
  • 453