'How to correctly use data in extdata/data folder

I am working on an R package that I would like to submit to CRAN and have had issues with the size of the data, therefore I moved it into the extdata/data folder in order to use in my examples but I am getting fatal errors that are not allowing my package to pass the checks.

The GitHub repo

I've tried a few different solutions (i.e. system.file() & load(system.file())) which have not worked. The files are RData files.

#' load(system.file("extdata", "trueLabels.RData", package = "DWLS"))
&
#' system.file("extdata", "trueLabels.RData", package = "DWLS")

How can I use the data in the extdata/data folder in my @examples of the functions without encountering build errors?



Solution 1:[1]

The main problem is that your files will not be available for loading with system.file until the package is installed. So at build time the examples will not have them, only will be there when the package is available, devtools::load_all() does not do the trick.

load(system.file('extdata','<filename>.RData', package = 'DWLS')) is the way to go, in any case.

You can find more info here and here

I've seen in your repo that you try to get the data with download.file() but failed at check job. You can try to use tmpfile() as destination.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 AdriÃ