检测 R 中的操作系统(例如,用于自适应 .Rprofile 文件) [英] detecting operating system in R (e.g. for adaptive .Rprofile files)

查看:13
本文介绍了检测 R 中的操作系统(例如,用于自适应 .Rprofile 文件)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道如何在 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 中包含的包使用 .Platform muchSys.info 更频繁.

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆