How to Keep Custom R Package Dependencies Self-Contained

I'm creating an R package for the first time to be shared, and some of my functions depend on functions from other packages. I've used roxygen2 to create documentation and import these other packages in the appropriate functions, but is that enough to keep users from having to update or install the packages it depends on when they install my package? From what I've seen the packrat package creates self-contained projects not packages, but is the way to go to use that somehow?

:wave: @m13op22!

Indeed your users will have to install the packages your package depends on, unless they have them already on their system (which might often be the case for popular packages!). They will need to update these dependencies only if your package indicates a minimal version in DESCRIPTION for instance

Imports: 
    commonmark (>= 1.6)

You might be interested in

I'm wondering why you want to keep your package self-contained? Approaches that might be of interest depending on your use case might involve Docker. Or maybe if you don't want anyone to install your package you could provide an API to your package via plumber. So really it will depend on your use case (and personal preferences). :smile_cat:

Last note, for projects packrat is superseded by renv (by the same author).

1 Like