Skip to content

Is there an inverse function of Sys.getenv()

2 messages · Michael, Uwe Ligges

#
Using "Sys.getenv()",

I got a list of 380 environment variables...

Now I open a new R session,

how do I set those environment variables in my new R session using
"Sys.setenv()"?

There is no batch function for "Sys.setenv()"?

Is there an import/export environment variables function?

Basically I want to export all the environment variables from one R
session and import them into another R session...

Thank you!
#
On 22.05.2012 20:48, Michael wrote:
You don't want to do that for all variables, not all of them are related 
to R, some related to other software products or even your OS (and hence 
perhaps important not to change them).


Anyway, to answer your question:

# get:
envVars <- Sys.getenv()
# set:
do.call(Sys.setenv, as.list(envVars))

Uwe Ligges