Sys.setenv
Set or Unset Environment Variables
Description
Sets or unsets environment variables that are used 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 might 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 specified variables to the environment and sets their values.
If a variable of the specified name already exists in the environment, Sys.setenv overwrites its value.
- Sys.unsetenv removes the specified variables from the environment or sets their
values to "" if the variables cannot be removed in some system platform.
Environment variables set by these functions are in effect
during the current session only. They can be retrieved by calling
Sys.getenv.
Value
returns 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. Use 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 # TRUE
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 ""