Set Environment Variables

DESCRIPTION:

Set environment variables for use by other processes called from S-PLUS.

USAGE:

Sys.setenv(...)
setenv(which, values)
Sys.putenv(...)

REQUIRED ARGUMENTS:

...
arguments having the 'name'='value' form, where the value must be coercible to a character string. Depending on the name or value, it may be necessary to quote the name or the value.
which
a character vector containing the names of one or more environment variables. Or, if the values argument is omitted, a named vector where the names are those of environment variables to set or modify.

OPTIONAL ARGUMENTS:

values
a vector containing the values of one or more environment variables. The length of this vector must match the length of which. Each value must be coercible to a character string.

VALUE:

a named vector of character strings giving the previous value of the environment variables that were set. The returned vector has a names attribute that holds the names of the environment variables. This returned value can be used to reset any altered environment variables to their previous values.

SIDE EFFECTS:

Adds the variables to the environment and sets their values. Or, if a variable already exists in the environment, its value is overwritten.

DETAILS:

setenv sets the variables given by which to the corresponding values in the values argument. If values is missing, which is expected to have a names attribute giving the names of the variables.

The functions Sys.setenv and Sys.putenv emulate the R functions of the same name, but R's version returns a logical vector having the same length as the input, with elements being true if setting the corresponding variable succeeded.

For the most portable code, use Sys.setenv, as Sys.putenv was declared deprecated in R 2.5.0.

Environment variables set by these functions are only in effect during this S-PLUS session and can be retrieved by calling getenv or Sys.getenv.

SEE ALSO:

(and Sys.getenv), (and setwd).

EXAMPLES:

# Set an environment variable using Sys.setenv
Sys.setenv("S_PRINT_ORIENTATION"="portrait")
# Set a variable using setenv
orig <- setenv("S_PRINT_ORIENTATION","portrait")
# reset to the original value
setenv(orig)