It is my understanding that R code passed on to reprex::reprex() is evaluated in a new, clean environment, so that no data or settings from the main R session are passed on.
reprex() takes the section of copied code and then runs rmarkdown::render() on it, which starts a fresh environment, and runs the code.
From the Magic reprex vignette
This does not seem to be true for environment variables though. Apparently, if I change an environment variable in my main R session, the change gets carried through to the reprex::reprex() environment.
Example: This code chunk was created with reprex::reprex()
Sys.getenv("R_TEST")
#> [1] ""
After I run Sys.setenv(R_TEST = "testit") in my main R session, reprex::reprex() shows this:
Sys.getenv("R_TEST")
#> [1] "testit"
Is this a bug or a feature?