I am writing a package which uses hierarchical data which are fixed (same across different applications of the package, such as a ), and which I built using the data.tree package.
Is it possible to export the data object? Would I rather use the data subdirectory to store the code in binary? Or in a json file? Or would I write and export R code which builds the structure from a downloaded file?
My recent attempts have been to store the data in *.rda files which I put in data (say, "topoTree.rda"), then document the file in topoTree.R and put the lines
@export topoTree
"topoTree"
at the end of the file. After running devtools::load_all() and devtools::document(), an object name topoTree is not exported.
Documenting functions • roxygen2 mentions that in most cases, functions are exported, but does not elaborate on exporting objects which are not functions.
The pivotal (to my problem) statement seems to be:
Sometimes your package functions need access to pre-computed data. If you put these objects in data/ , they’ll also be available to package users, which is not appropriate.
But in my case, this would be perfectly appropriate, since I want the data structure accessible to user, not only via predefined functions.
So load("/path-to-package/data/topoTree.rda")associates the tree object with topoTree. data(topoTree)doesn't. Which user-level command does the trick, even when user does not know path-to-package?