rpackrat

Initialising packrat for new project so it contains existing packages


I want to start using package management for R projects. I am trying to use the packrat package. When I start a new project, I select the "Use packrat with this project" in the GUI. Or I could use packrat::init(). Both work OK. However, unless I am misunderstanding, this only initialises with a selection of packages which means I have to re-install lots of packages manually?

For example, after starting a project from scratch I have to re-install ggplot2 or pool or many others manually but not e.g. dplyr or DBI.

My question is, can I edit the list of standard packages that get initialised for a new project? Otherwise, for every new project I create I will have to go through and manually install lots of packages. I feel like I am missing a crucial step somewhere?


Solution

  • I would say create a new directory call the directory: "Quickstart." Then install packrat and all the libraries you want to use into Quickstart.

    Then when you want to start new project:

    1. copy/paste the Quickstart/packrat folder into your new project directory
    2. copy/paste the Quickstart/.Rprofile file into your new directory

    Now your new project should have all the starting libraries and packrat initiated.