tags:

views:

165

answers:

3

Is there a simple way to programmatically determine if an R script is being executed in Windows vs. Linux?

+4  A: 

.Platform$OS.type

returns

[1] "unix"

or something else.

Spacedman
See also R.version() for other OS-type things.
Spacedman
hmm.. R.version() doesn't work... maybe Sys.info()?
JD Long
ahh.. capitalization. It's R.Version()
JD Long
+5  A: 

if(.Platform$OS.type == "unix"){ }else {

}

Dan
i shouldn't have wasted that time with the first comment. Beaten to the punch again.
Dan
If it had been a useful comment, I would be sympathetic... But that one was really wasted time! :)
Pekka
Thanks! I could not remember this to save my life.
JD Long
+5  A: 
Sys.info()["sysname"]
rcs