2011-01-20 26 views
28

可能重複:
detecting operating system in R (e.g. for adaptive .Rprofile files)
How can I determine in R what platform I'm running on?如何R內部檢查操作系統

是否有R A原函數上的R運行,將返回有關係統的信息?我主要關注操作系統,但其他任何數據都可能有幫助。

+1

看起來像重複[在R中檢測操作系統(例如對於自適應.Rprofile文件)](http://stackoverflow.com/questions/4463087/detecting-operating-system-in-reg-for-adaptive-rprofile-文件) – Marek 2011-01-20 13:40:53

+1

而這一個:http://stackoverflow.com/questions/3919621/how-can-i-determine-in-r-what-platform-im-running-on/3922058#3922058 – 2011-01-20 13:50:18

回答

33

有關係統的所有信息使用Sys.info()Sys.info()['sysname']給你的操作系統。

R.Version()爲您提供R的版本,包括您正在運行的架構(32位 - i386 - 與64位 - x64 - )。

R.home()system.file(package="xxx")爲您提供根區域的位置信息。包文件。

25

這裏有三種方式:

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

看看?Sys.info的一些細節和附加條件。