Why can't you have several version of a r-package in a given r-library

1k views Asked by At

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')
1

There are 1 answers

4
Stibu On

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.