R - where should I place RDA file - /R, /data, /inst/extdata?

浪子不回头ぞ 提交于 2019-12-04 18:38:16

问题


According to the "Writing R Extensions" manual, there are three directories where RDA files can be placed: /R, /data, /inst/extdata

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.

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)


回答1:


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.

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.




回答2:


You should probably be leaving the ../data/ directories in the package directories alone. Most serious users will have separate project directories in which they store their own data files. They then change the default "focus" using setwd().



来源:https://stackoverflow.com/questions/6113510/r-where-should-i-place-rda-file-r-data-inst-extdata

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!