Best practice for editing default packages on startup? RRS feed

  • Question

  • Hello everyone,

    I know this is a practice that many people discourage, but I and many other people find it useful to edit the file to include list of packages to always load into the session. The code I've used in GNU-R is a simple:

    options(defaultPackages = c(getOption("defaultPackages"),newDefaults))

    where newDefaults is a character vector of my standard packages. Is there a best practice now that I'm making the jump to MRO? I see a lot of differences in how the two versions start up and would love to know how that would effect the method I've been using.

    Thank you kindly

    Wednesday, May 25, 2016 5:42 PM


  • Changing the global package list is something I don't generally recommend, as it makes it hard to share code with others that don't have the same configuration. The exception I make is for corporate teams that share code using a custom set of R packages (and in which case these are the people you'll be sharing with, anyway).

    My recommendation would be to use the checkpoint package to achieve what you want on a per-project basis. One trick to note is that checkpoint scans all your .R files for any library()/require() calls, and makes sure the packages you mention are available. So you could create a file "standardpackages.R" containing only lines like:


    and copy that file into every new project. Then at the top of your main script file, add:


    (or use any date you like), and checkpoint will make sure that all the packages in your standardpackages.R file will be available to your script, without changing the package environment for any other R projects.

    Hope this helps!
    David Smith

    • Marked as answer by leCygneRouge Wednesday, May 25, 2016 9:11 PM
    Wednesday, May 25, 2016 6:33 PM