I'm building a Shiny app as an internal package (ie. not to be deployed to CRAN or publicly accessible, just installable by coworkers). The app also uses reticulate, so I currently have a package structure that looks like:
DESCRIPTION
NAMESPACE
README.md
LICENCE
R/
|---package-launch.r
|---package-server.r
|---package-ui.r
|---configure-reticulate.r
inst/
|---assets
|---background.png
|---python
|---daily_processing.py
|---indices.py
|---internaldata
|---something.csv
I refer to the python scripts using:
reticulate::import_from_path('indices',
path = file.path(find.package('mypackage'), 'inst', 'python'))
While I retrieve other assets with:
system.file('inst', 'internaldata', 'something.csv', package = 'mypackage')
While I'm testing using devtools
(using document)
and load_all()
), this works great. But if someone installs the package, the contents of inst
is raised a level, and the files can't be found anymore. But if I don't refer to inst
, I can't access the files without installing the package myself—simply using load_all()
doesn't move the files.
Should I be accessing or storing the files differently? (Since this package is internal, it doesn't need to pass CRAN checks, but it should install without an issue!)
EDIT: The R package book says to store raw data in inst/extdata
and to refer to them using system.file()
without inst
" To refer to files in inst/extdata
(whether installed or not)" (emphasis mine). My experience is that for othe subfolders in inst
, this doesn't work unless installed. Is inst/extdata
special here?