reprex code containing passwords

I have a code that makes use of passwords that I have in my .Rprofile and without the right user password, the code doesn't work.
Is there a way to pass a variable to reprex from the global environment or to make use of the current .Rprofile in the reprexed code ?

Thanks

Yes, you can set environment variables in a .Rprofile or .Renviron file and then read from the file in another script using Sys.getenv.

password <- Sys.getenv("PASSWORD_ENV_VAR")

Unfortunatly, the way it is setup is that the Rprofile creates a new environment and all the username and passwords are within that new environment. This is an example of the way it's done in the .Rprofile

pwd_env <- new.env()
pwd_env$username = "my_user_name"
pwd_env$password= "my_password"

and I would like to make this new environment accessible to reprexed code
Your solution is a good one but it's not exactly what I want (I'm sorry if my question wasn't really clear)

Thanks

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.