Sys.setenv
Set or Unset Environment Variables
Description
Set or unset environment variables for use by other processes called from
the engine.
Usage
Sys.setenv(...)
Sys.unsetenv(x)
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.
|
x |
a character vector containing the names of one or more
environment variables.
|
Details
Sys.setenv adds the variables to the environment and sets their values.
Or, if a variable already exists in the environment, its value is overwritten..
Sys.unsetenv removes the variables from the environment. Or sets their
values to "" if the variables can't be removed in some system platform.
Environment variables set by these functions are in effect
only during this session and can be retrieved by calling
Sys.getenv.
Value
a logical vector having the same length as the input, with elements
being true if setting or unsetting the corresponding variable succeeded.
Note
Sys.putenv is deprecated, using Sys.setenv instead.
See Also
Examples
# Set an environment variable using Sys.setenv
ret <- Sys.setenv("S_PRINT_ORIENTATION"="portrait")
ret # TRUE
Sys.getenv("S_PRINT_ORIENTATION")
# Unset a variable using Sys.unsetenv
ret <- Sys.unsetenv("S_PRINT_ORIENTATION")
ret # TRYE
Sys.getenv("S_PRINT_ORIENTATION")
# Unset a non-existing variable in Windows platform.
ret <- Sys.unsetenv("S_NOT_EXIST")
ret # TRUE
Sys.getenv("S_NOT_EXIST") # returns ""