Skip to content

Instantly share code, notes, and snippets.

@jeroenjanssens
Last active June 8, 2018 08:39
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jeroenjanssens/985693c5485ea92d13eb to your computer and use it in GitHub Desktop.
Save jeroenjanssens/985693c5485ea92d13eb to your computer and use it in GitHub Desktop.
Sensitive information in R scripts

If your R script uses senstive information such as a password, then it's best to keep this in a seperate file (and perhaps outside the project's repository). Moreover, if you're giving a live demo using RStudio, then you should avoid putting this senstive information in your global environment.

If you put it in a YAML file, say .my_project.yaml, which may look as follows:

---
api_service:
  username: foo
  password: bar123!

then you can easily load these settings in R using:

library(yaml)
options(my_project = yaml.load_file(".my_project.yaml"))

which you can then access with getOption("my_project")$api_service$password.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment