在R中检测操作系统(例如,针对自适应.Rprofile文件) [英] detecting operating system in R (e.g. for adaptive .Rprofile files)
问题描述
我想知道如何在R中自动检测操作系统,例如将内容放置在.Rprofile中.
I was wondering how to automatically detect operating system in R, for example to place things in the .Rprofile.
推荐答案
我不确定是否要使用Sys.info()
,因为帮助页面上说它不是在所有R平台上都实现的;也许改用.Platform
吗? ?.Platform
具有很多有用的信息,因为:
I'm not sure about using Sys.info()
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"是包含一些内容的列表 R平台的详细信息 被建.这提供了手段 编写操作系统可移植的R代码.
‘.Platform’ is a list with some details of the platform under which R was built. This provides means to write OS-portable R code.
似乎R附带的软件包比Sys.info
更频繁地使用.Platform
.
It also seems the packages included with R use .Platform
much more frequently than Sys.info
.
josh: /c/R/R-2.12.0-src/src/library
> grep ".Platform" */R/* | wc -l
144
josh: /c/R/R-2.12.0-src/src/library
> grep ".Platform\$OS.type" */R/* | wc -l
99
josh: /c/R/R-2.12.0-src/src/library
> grep "Sys.info" */R/* | wc -l
4
这篇关于在R中检测操作系统(例如,针对自适应.Rprofile文件)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!