My package includes raw data in .csv
files, but I want them to be processed using an R script placed in the data/
directory. I've placed the raw data files in inst/extdata
.
data_locs = c(file.path("..", "inst", "extdata"),
file.path("..", "extdata"),
file.path("extdata"),
file.path("inst", "extdata"))
data_loc = data_locs[file.exists(data_locs)]
files = file.path(data_loc,
list.files(data_loc, pattern=".*\\.csv"))
datalist = lapply(pubtime_files, utils::read.csv)
data = do.call(rbind, datalist)
rm(datalist, files, data_loc, data_locs)
I use the multiple data_locs
because the working directory used when roxygenizing is different than when building the package, but even with this, list.files
doesn't find any files and I get:
==> R CMD INSTALL --no-multiarch --with-keep.source PACKAGE
* installing to library ‘/Users/noamross/Library/R/3.0/library’
* installing *source* package ‘PACKAGE’ ...
** R
** data
*** moving datasets to lazyload DB
Error in datalist[[1]] : subscript out of bounds
How do I load the data in extdata
with a script in data/
?