I have developed a series of learnr tutorials to accompany two of my textbooks. In both cases I have wrapped them in packages (adventr and discovr) rather than deploying on a shiny server (because of large student numbers and the desire to make them available for others without escalating my server costs). I have started to wonder about the best way to deal with dependencies for these packages. The tutorials cover a lot of ground, so across all of the tutorials within a package they use 20-30+ external packages. The tutorials need these external packages to run. So, how best to deal with that?
Currently I list external packages as Imports in the description file of the package and advise people to install using dependenices = TRUE
. That way, all dependencies should be installed along with my package and all tutorials within my package will run. But this means users potentially get 30+ packages installed in one hit. I also get warnings when I build the package because of the large number of dependencies. However, if the external packages are not installed on the user's machine, the userswill get errors when they try to run the tutorials.
However, I gather that in the latest release of learnr/RStudio tutorials are compiled directly from the markdown (i.e. I don't need to pre-render the htmls and distribute them), which made me wonder whether a better approach would be to code a require for each package within a particular tutorial ... so, in the setup for each tutorial there is code that checks if the required packages exist and if they don't they are installed. That way, I could have minimal dependencies for the package overall, users won't have to install all dependencies in one hit - they'll get installed on a per-tutorial basis when they run it. Would this approach work?
Any advice/recommendations would be appreciated on best practice for package dependencies for learnr tutorials when wrapped in a package?
Thanks
andy