Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

r

packages

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)

like image 904
SFun28 Avatar asked May 24 '11 16:05

SFun28


People also ask

What does Extdata mean in R?

See this section of the R packages guide. inst/extdata is where packages store "external data" e.g. data files used for examples in the package documentation.

How do I load data into an R package?

If you look at the package listing in the Packages panel, you will find a package called datasets. Simply check the checkbox next to the package name to load the package and gain access to the datasets. You can also click on the package name and RStudio will open a help file describing the datasets in this package.


1 Answers

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.

like image 194
Dirk Eddelbuettel Avatar answered Sep 19 '22 15:09

Dirk Eddelbuettel