如何从R检查OS X版本? [英] How to check the OS X version from R?
问题描述
您可以使用 Sys.info()["sysname"] =="Darwin"
检查是否正在运行OS X.
You can check whether you are running OS X using Sys.info()["sysname"] == "Darwin"
.
在Windows上,可以通过使用 utils :: win.version()
检查操作系统的特定版本来进行更好的控制.
On Windows, finer control is possible by checking for specific versions of the OS using utils::win.version()
.
如何检查OS X的版本?(我找不到 mac.version
或 osx.version
函数.有一些低级OS命令可用于查找版本,但我不知道任何R包装器.)
How do you check the version of OS X? (I can't find a mac.version
or osx.version
function. There are some low-level OS commands for finding the version, but I'm not aware of any R wrapper.)
Sys.info()["release"]
或 system("uname --kernel-release",intern = TRUE)
是否返回有用的东西?(我没有机器可以检查.)
Do Sys.info()["release"]
or system("uname --kernel-release", intern = TRUE)
return anything useful? (I don't have a machine to check.)
推荐答案
Sys.info()["sysname"]
在Mac OS X上返回"Darwin".
Sys.info()["sysname"]
returns "Darwin" on Mac OS X.
Sys.info()[版本"]
告诉您Mac OS X的版本.例如,"13.4.0"是Mac OS X 10.9.5.
Sys.info()["release"]
tells you what version of Mac OS X. For example, "13.4.0" is Mac OS X 10.9.5.
可能不需要执行 system()
调用: Sys.info()["version"]
似乎返回与完全相同的结果系统("uname -v")
.而且此版本确实结合了不同的信息,因此不方便仅检查您是否在Mac上运行.例如
There probably is no need to do a system()
call: Sys.info()["version"]
seems to return exactly the same as system("uname -v")
. And this version really combines different pieces of information and is not convenient for just checking whether or not you're running on Mac. For example
> Sys.info()["version"]
version
"Darwin Kernel Version 13.4.0: Wed Mar 16 09:03:04 PDT 2015; root:xnu-2422.115.14~1/RELEASE_X86_64"
这篇关于如何从R检查OS X版本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!