R-我应该在哪里放置RDA文件-/R,/data,/inst/extdata? [英] R - where should I place RDA file - /R, /data, /inst/extdata?
问题描述
根据"Writing R Extensions"手册,可以在三个目录中放置RDA文件:/R
,/data
,/inst/extdata
According to the "Writing R Extensions" manual, there are three directories where RDA files can be placed: /R
, /data
, /inst/extdata
从手册中破译最佳实践确实非常困难.有人可以评论何时/为什么将RDA文件放置在这三个目录中.
Its really hard to decipher the best-practice from the manual. Could someone comment on when/why to place RDA files in each of these three directories.
以下是我要解决的具体情况:
我有1个RDA文件,该文件将在函数示例以及我的test_that测试中使用(所有代码都存储在inst/tests中)
Here's the specific cases I'm solving for:
I have 1 RDA file that will be used in function examples as well as in my test_that tests (which all live in inst/tests)
推荐答案
从 手册开始进行软件包编写,这使我印象深刻. data/
目录对我来说似乎是个好选择.我记得,对于非R数据集或某些此类数据集,建议使用inst/extdata
.
Starting with the manual for package writing strikes me as a good approach. The data/
directory looks like a good bet to me. As I recall, inst/extdata
was suggested for non-R data sets or some such.
一般规则仍然是inst/
下的所有目录都将按原样复制; data/
目录可以被转换.该手册将有详细信息.因此,如果只希望将其用于回归测试,则可以使用inst/testData
(例如),一旦安装了该软件包,就可以使用system.file("testData", package="yourPackageNameHere")
对其进行计算.
The general rule still is that all directories below inst/
will be copied as-is; the data/
directory may be transformed. The manual will have details. So if you wanted it just for regression tests, you could use inst/testData
(say) and, once the package is installed, you can use system.file("testData", package="yourPackageNameHere")
to compute it.
这篇关于R-我应该在哪里放置RDA文件-/R,/data,/inst/extdata?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!