.Platform
is a list with some details of the platform under
which R was built. This provides means to write OS-portable R
code..Platform
"unix"
or "windows"
.
"/"
on both Unix-alikes and on Windows (but
not on the former port to Classic Mac OS).
".dll"
on
Windows and ".so"
or ".sl"
on Unix-alikes. (Note for
macOS users: these are shared objects as loaded by
dyn.load
and not dylibs: see dyn.load
.)
"unknown"
if no GUI can be assumed. Possible values are for Unix-alikes the
values given via the -g command-line flag ("X11"
,
"Tk"
), "AQUA"
(running under R.app
on macOS),
"Rgui"
and "RTerm"
(Windows) and perhaps others under
alternative front-ends or embedded R.
"big"
or "little"
, giving the
‘endianness’ of the processor in use. This is relevant when it is
necessary to know the order to read/write bytes of e.g. an
integer or double from/to a connection: see
readBin
.
options("pkgType")
. Values "source"
,
"mac.binary.mavericks"
and "win.binary"
are currently
in use. This should not be used to identify the OS.
":"
on Unix-alikes and
";"
on Windows. Used to separate paths in environment
variables such as PATH
and TEXINPUTS
.
""
. The name of an
architecture-specific directory used in this build of R.
.Platform$GUI
is set to "AQUA"
under the macOS GUI,
R.app
. This has a number of consequences:
/usr/local/bin
is appended to the PATH
environment variable.
quartz
.
graphics
= TRUE
options of menu
and select.list
.
R.version
and Sys.info
give more details
about the OS. In particular, R.version$platform
is the
canonical name of the platform under which R was compiled. .Machine
for details of the arithmetic used, and
system
for invoking platform-specific system commands. capabilities
and extSoftVersion
(and links
there) for availability of capabilities partly external to R
but used from R functions.## Note: this can be done in a system-independent way by dir.exists()
if(.Platform$OS.type == "unix") {
system.test <- function(...) system(paste("test", ...)) == 0L
dir.exists2 <- function(dir)
sapply(dir, function(d) system.test("-d", d))
dir.exists2(c(R.home(), "/tmp", "~", "/NO")) # > T T T F
}
Run the code above in your browser using DataLab