First, to get the environment variable, you need to put quotation marks there:
Sys.setenv(ENV_VAR = 1) Sys.getenv("ENV_VAR")
Secondly, as Chase said, the new environment is the way to go, but you must also attach it:
e <- new.env() e$foo <- 42 attach(e, name='myvars') rm(list=ls())
... and disconnect it:
detach('myvars')
source share