Search code examples
rconfigr-package

Where to put config.yml in an R package


I am creating an R package that uses the config package to read a config.yml file.

My question is: where does config.yml go? config.get() expects it to be in the root directory, so if I put it at <my_package>/config.yml, it locates it with no problem. However, devtools::check() hates this:

Non-standard file/directory found at top level: 'config.yml'

The closest explanation I've seen for what you are supposed to do only applies to when the config file is only used for unit tests. That's not my case; I need this config to actually be used by the package itself. I know I could fix this by just putting it in a directory like <my_package>/R/ and replacing every invocation of config::get() with something like config::get(here::here('R/config.yml')), but that seems hacky.

Is there a recommended way to do this?


Solution

  • Goes under inst/. Access the actual location with

    system.file('config.yml', package = '<my_package>', mustWork = TRUE)