getenv(var) Sys.getenv(var)
var is missing, the
entire environment is returned.
var, or the values of all environment variables if
var is
omitted. If an element of
var is not the name of an environment
variable, the corresponding element of the returned vector will be the
null string ("").
S-PLUS uses several environment variables, such as those in the example section. This function can be used to retrieve the value of any environment variable, not just those set by S-PLUS.
The
Sys.getenv function is just a wrapper for
getenv.
It is provided for source code compatibility with other S language dialects.
getenv("HOME")
getenv("S_PRINT_ORIENTATION") # might return "landscape" (on Unix)
shome <- "SHOME"
getenv(shome) # returns character string of the S-PLUS home directory
all.env <- getenv() # whole environment
leading.S <- grep("^S", names(all.env))
# index into all.env for those names starting with 'S'
all.env[leading.S]
# values of these variables; names are preserved
getenv(c("SHOME", "S_FIRST"))
getenv()[c("SHOME", "S_FIRST")] # same thing