| Sys.setenv | R Documentation |
Sys.setenv sets environment variables (for other processescalled from withinR or future calls toSys.getenv fromthisR process).
Sys.unsetenv removes environment variables.
Sys.setenv(...)Sys.unsetenv(x)
... | named arguments with values coercible to a character string. |
x | a character vector, or an object coercible to character. |
Non-standardR names must be quoted inSys.setenv: see theexamples. Most platforms (and POSIX) do not allow names containing"=". Windows does, but the facilities provided byR may nothandle these correctly so they should be avoided. Most platformsallow setting an environment variable to"", but Windows doesnot and thereSys.setenv(FOO = "") unsetsFOO.
There may be system-specific limits on the maximum length of thevalues of individual environment variables or of names+values of allenvironment variables.
Recent versions of Windows have a maximum length of 32,767 characters for aenvironment variable; howevercmd.exe has a limit of 8192characters for a command line, henceset can only set 8188.
A logical vector, with elements being true if (un)setting thecorresponding variable succeeded. (ForSys.unsetenv thisincludes attempting to remove a non-existent variable.)
On Unix-alikes, ifSys.unsetenv is not supported, it will atleast try to set the value of the environment variable to"",with a warning.
Sys.getenv, Startup for ways to set environmentvariables for theR session.
setwd for the working directory.
The help for ‘environment variables’ lists many of theenvironment variables used byR.
print(Sys.setenv(R_TEST = "testit", "A+C" = 123)) # `A+C` could also be usedSys.getenv("R_TEST")Sys.unsetenv("R_TEST") # on Unix-alike may warn and not succeedSys.getenv("R_TEST", unset = NA)Add the following code to your website.
For more information on customizing the embed code, readEmbedding Snippets.
