【问题标题】:Is it possible to identify if R is being run in unix or windows environment [duplicate]是否可以确定 R 是否在 unix 或 Windows 环境中运行[重复]
【发布时间】:2014-12-23 13:25:51
【问题描述】:

我需要为我的代码设置不同的路径,具体取决于它是在 windows 还是 unix 中运行。我目前已对其进行了设置,因此用户必须在运行之前更改变量“Renvironment”,如下所示。

Renvironment <- "windows"

if (Renvironment == "windows") {
  working_dir <- "windows_path..."
  function_library <- "windows_path..."
} else if (Renvironment == "unix") {
  working_dir <- "unix_path..."
  function_library <- "unix_path..."
}

我想知道是否可以使用默认的 R 环境变量来代替用户必须记住手动更改变量?

【问题讨论】:

    标签: r


    【解决方案1】:

    .Platform 命令返回平台的详细信息。您可以使用

    访问有关操作系统的信息
    .Platform$OS.type
    

    这将返回 "unix""windows"

    【讨论】:

    • 感谢您的帮助
    猜你喜欢
    • 2013-12-18
    • 2020-12-17
    • 1970-01-01
    • 1970-01-01
    • 2016-12-18
    • 1970-01-01
    • 2022-01-10
    • 1970-01-01
    • 2011-02-13
    相关资源
    最近更新 更多