I have an R package with internal data (by design stored in R/sysdata.rda). I would like to update one of the objects in it, or add an object to it.
The usethis package has the use_data() and use_data_raw(), but they do not (and seem to will not) support this possibility (see r-lib/usethis#1512 and r-lib/usethis#1091).
How can this still be accomplished? I would like to not interfere with my global (user) environment.
This answer is just a solution for a specified use case. Whether this is a recommendable workflow is not part of this question or answer. I only show how this can be made possible in R.
Problem explanation
Per the
usethis::use_data()documentation, it is indeed not possible to do this, as the...must contain "Unquoted names of existing objects to save" (so you cannot add a list with objects) and there is noaddargument:Solution
You can load your current
sysdata.rdato a separate environment, alter it (by adding of changing objects) and then save it again usingsave()(thatuse_date()actually calls internally):Though for the best portability and lowest space used, you might want to use: