将config.yml放在r软件包中

发布于 2025-02-10 20:47:39 字数 835 浏览 1 评论 0原文

我正在创建一个使用 config.yml 文件。

我的问题是:config.yml去哪里? config.get()期望它位于根目录中,因此,如果我将其放在< my_package>/config.yml中,它将毫无问题地定位它。但是,devtools :: check()讨厌以下内容:

在顶级找到的非标准文件/目录: 'config.yml'

最近的说明我已经看到,仅当仅将配置文件用于单元测试时,我应该做的事情。那不是我的情况;我需要该配置实际上由软件包本身使用。我知道我可以通过将其放入< my_package>/r/之类的目录中来解决此问题,然后替换conify> config> contig> get()带有config :: get之类的东西(there ::此处('r/config.yml')),但这似乎是黑客的。

有建议这样做吗?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

情释 2025-02-17 20:47:39

进入Inst/。访问实际位置

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

Goes under inst/. Access the actual location with

system.file('config.yml', package = '<my_package>', mustWork = TRUE)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文