Saving R6 class template within R package

Viewed 90

I am making a package which uses an R6 class.

As part of the internal data of the package I have a list of objects of my R6 class. I have a script in data-raw that has the class template, in which I generate some objects (all of the same class) and the list.

One of the functions of the package allows users to add a new object to this list, so I want to be able to build a new object from the same template.

I thought I'd save the class template within the internal data using

usethis::use_data(CT,overwrite=TRUE,internal=TRUE)

where CT is my class template.

This doesn't seem to work - when I install and load the package I can't find CT when doing myPackage:::CT, so I guess it's not possible to save a template as data.

Does anyone know the correct way of doing this?

Thanks.

0 Answers
Related