exporting data which are not in a tabular structure

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.

I seem to fundamentally misunderstand something.

A good source of info on package development is R Packages (2e) - 8 Data (r-pkgs.org) <- this is the data chapter.

I think the key point is the use of LazyData: true in your DESCRIPTION

This looks very helpful indeed, many thanks!

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?

This topic was automatically closed after 45 days. New replies are no longer allowed.


If you have a query related to it or one of the replies, start a new topic and refer back with a link.