Reputation: 7517
I was wondering if there might be a logical test in R to evaluate whether R is Running under a "Windows" (win
) OS or not?
if("OS is windows") { ## Here is the logical test I need !!!
setwd("~/../Desktop")
} else {
setwd("~") }
x <- paste0(getwd(),"/", "Animation")
dir.create(x)
Upvotes: 1
Views: 369
Reputation: 3007
Here is a function that might help:
https://github.com/hadley/rappdirs/blob/master/R/utils.r#L1
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")
}
}
Upvotes: 4