Persistent Package Configuration
Store the configuration of your package in the user's platform dependent config file directory. The configuration persists across R sessions, and can also be edited manually. Configuration files are YAML files.
Once on CRAN, install the package with:
install.packages("conf")
library(conf)
conf
uses the rappdirs
package (https://github.com/hadley/rappdirs) to
determine the appropriate location of the configuration file of a package.
To determine the location of the configuration file, you can use:
conf$new(package = "mypackage")$get_path()
#> [1] "/Users/gaborcsardi/Library/Application Support/r-config/mypackage/config.yaml"
Create a configuration file by creating a conf
object, then setting
some configuration keys in it, and writing it out to a file:
cf <- conf$new(package = "mypackage", lock = TRUE)
cf$set("user:id", "test-user")
cf$set("user:email", "test@acme.com")
cf$set("rversion", format(getRversion()))
cf
#> user:
#> id: test-user
#> email: test@acme.com
#> rversion: 3.5.3
cf$save()
MIT © RStudio Inc