How to check for missing packages and install them?

Looking for an elegant way to check for missing packages and install them at the beginning of a R project where I need to set the Repos location (ie repos = https:// cran .....)

Jeff

I am not sure if we always can know which packages are missing at the beginning of an R project. For me the most elegant way I am aware would be to

  • start with a local .Rprofile in the project directory where you can add all the repo settings (unless this is already defined in your R installation (Rprofile.site) or in the RStudio setup (rsession.conf).
  • use renv which will not only auto-detect missing packages and install them as needed, it will also maintain a file named renv.lock where all the packages and versions are recorded. If you then share the project with other colleagues, they can bootstrap the same environment based on renv.lock alone with exactly the same packages and versions for a maximum level of reproducibility.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.