是否可以确定R是在unix环境中运行还是在windows环境中运行

是否可以确定R是在unix环境中运行还是在windows环境中运行,r,R,我需要为我的代码设置不同的路径,这取决于它是在windows还是unix中运行。我目前已经对其进行了设置,以便用户在运行之前必须更改变量“Renvironment”,如下所示 Renvironment <- "windows" if (Renvironment == "windows") { working_dir <- "windows_path..." function_library <- "windows_path..." } else if (Renviro

我需要为我的代码设置不同的路径,这取决于它是在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..."
}

Renvironment命令
.Platform
返回平台的详细信息。您可以使用访问有关操作系统的信息

.Platform$OS.type

这将返回
“unix”
“windows”

命令
.Platform
返回平台的详细信息。您可以使用访问有关操作系统的信息

.Platform$OS.type

这将返回
“unix”
“windows”

谢谢您的帮助谢谢您的帮助