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
.