1

Is it possible to access several versions of the same package in a given library ? I see many projects online like miniCRAN or versions or cranium but they all allow the same thing which is allow a user to build a given version of a package.

My problem is that I have several users that need to run their code as the same prod user so they might need different versions of the same package.

Is there something that would enable me to do essentially

R) library(my_package, version='1.0.1')
statquant
  • 13,672
  • 21
  • 91
  • 162

1 Answers1

3

As far as I know, it is not possible to install multiple versions of a package in a library. But you can have multiple libraries on you computer and and install the various versions of the packages into these.

You can give a path for the library to be used when you install a package:

install.packages("my_package", lib = "path/to/library")

In this way, you could install different versions of a package to different libraries. When loading a package, you can again specify from which library you want to load it:

library(my_package, lib.loc = "path/to/library")

There are also packages that help you to use separate libraries for different projects. One example is packrat. Unfortunately, I have never used it myself, but there is a "Quick Start Guide" on their GitHub page.

Stibu
  • 15,166
  • 6
  • 57
  • 71
  • packrat solves the problem of 'how do I deploy a package truly self contained as it contains all the libraries it uses' but does not solve the 'how do I acces any package of any version' – statquant May 18 '18 at 14:57
  • @statquant I don't think that it is possible to 'deploy a package truly self contained'. The packrat webpage speaks of "R projects" not "R packages". So, assuming that you are not using various versions of an R package in the same project, packrat should be able to do exactly what you asked for. – Stibu May 18 '18 at 15:04
  • I do not think so... packrat is to build packages not libraries (set of built packages) – statquant May 18 '18 at 15:37
  • Well, as I said, I haven't used it, so I might be wrong. It's just that the docs say that packrat "creates a private package library" for a project and never mentions that it can be used to build packages (http://rstudio.github.io/packrat/, section "Basic concepts"). But it's not useful to fight about this here, so I suggest that we agree to disagree on this... – Stibu May 18 '18 at 15:49