Best practice for creating package data of a class defined in the package?


I'm writing a package for reading text files in an industry-standard format. Because the format (which is fixed-width) reserves space for custom fields, the package needs to allow users to define those fields. I decided to define a class named record_format for users to organize that data. Right now, the class is just a data.table with certain columns.

I'd like my package to eat its own dogfood and store the official field definitions as a record_format object. But this risks a loop when building the package: the data is created using a function in the package, which cannot be built until the data is created.

R's official documentation says data files can be .R scripts, but it then says

Note that R code should be “self-sufficient” and not make use of extra functionality provided by the package

So what's a good way to do this?