I've got a package which a whole bunch of miscellaneous functions (see What to do with imperfect-but-useful functions? ). Because the functions are not particularly related, they depend on a whole bunch of other packages. Often there will be just one function in the whole package which uses another package. Yet if I use Imports, Suggests, or Depends in the DESCRIPTION file, the whole list of packages will be loaded each time my package is loaded, even though very few of them are needed by any given user.
Is there any way to just load the dependencies only when a particular function is used? I could put a call to library()
inside the function themselves, but that seems like bad practice since it doesn't tell the package management system anything and therefore the user might not have it installed.