Adding a dataset to a package
Packages are also used to deliver research and research results to people and make them reproducible. Therefore, it is often necessary to include a dataset in our R package. Many packages also use this possibility to include this data into their demo code, to give users the possibilities to execute a demo version of the package's functions instantly without the need to import your own data.
To include this data, R provides several options. The choice of the option depends on what kind of data we want to attach to the package and what this data will be used for.
The most common way is to include it in the data
subdirectory. This way is often used when our dataset is used for the example code. Another way to include it is an .rda
file in the sysdata.rda
file. We can use this function if we do not want the package's users to have full access to these datasets.
The data files we can include in the package can be in three formats:
R code
Tables (
.txt
or.csv*
files)Save...