0

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?

Pete900
  • 2,016
  • 1
  • 21
  • 44
  • That's exactly how these things are supposed to work. packrat keeps everything isolated so no one project will interfere with another and updating a package for one project won't break a different project. What exactly are you using packrat for if you don't want this feature? Different versions of dplyr may have breaking changes. But if this is what you really want, look at the "external.packages" options you can set in the `?packrat-options` help page – MrFlick Feb 13 '18 at 18:34
  • 1
    No, I do want this feature. But, let's say I have an industrial day and start 3 new projects for which I use the same 10 packages. That means, I will have to go through the process of installing 10 packages, 3 times each. I wondered if there was a way to have those 10 packages install automatically during `init()`? – Pete900 Feb 14 '18 at 08:44
  • @MrFlick, I have the same issue with packrat. I only care portability across R versions, but don't mind if it is updated package. If I have 10 projects, initializing packrat for every project is duplicating and increases size of the folders. Then should I avoid packrat or is there a better way to manage ? . – user5249203 Jan 10 '19 at 16:48
  • The thing I like with packrat is, the .lock file. It assures me that I tested my code successfully with this set of packages/versions. So, when I send it to other user he can use the same package and version without any issues, even though he is using different version of R. But, would be nice if his local packages are either upgraded or downgraded rather than recreating subset of folders for each project. Unlike a package developer, users mostly likes prefers to use the latest update of the package. They may be selective on R versions, unless a major update – user5249203 Jan 10 '19 at 16:51

1 Answers1

0

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.

Frank
  • 952
  • 1
  • 9
  • 23