R能否知道它是否在Windows上运行?
我想知道R中是否有逻辑测试来评估R是否在“Windows”(R能否知道它是否在Windows上运行?,r,macos,operating-system,R,Macos,Operating System,我想知道R中是否有逻辑测试来评估R是否在“Windows”(win)操作系统下运行 这是干什么用的: if(“OS是windows”){###这是我需要的逻辑测试!!! setwd(“~/../Desktop”) }否则{ setwd(“~”} x以下是一个可能有帮助的函数: 下面是一个可能有帮助的函数: get\u os if("OS is windows") { ## Here is the logical test I need !!! setwd("~/../Desktop")
win
)操作系统下运行
这是干什么用的:
if(“OS是windows”){###这是我需要的逻辑测试!!!
setwd(“~/../Desktop”)
}否则{
setwd(“~”}
x以下是一个可能有帮助的函数:
下面是一个可能有帮助的函数:
get\u os
if("OS is windows") { ## Here is the logical test I need !!!
setwd("~/../Desktop")
} else {
setwd("~") }
x <- paste0(getwd(),"/", "Animation")
dir.create(x)
get_os <- function() {
if (.Platform$OS.type == "windows") {
"win"
} else if (Sys.info()["sysname"] == "Darwin") {
"mac"
} else if (.Platform$OS.type == "unix") {
"unix"
} else {
stop("Unknown OS")
}
}