knitr::opts_chunk$set(
  comment = "##",
  tidy = FALSE,
  error = FALSE,
  fig.width = 8,
  fig.height = 8)

Loading two versions for the same package

Introduction

Proof of concept, to load multiple versions of the same R package at once.

Testing

We install two versions of the same package, in temporary directories. Temporary directories first.

library(camo)
library(magrittr)
tmp1 <- tempfile() 
tmp2 <- tempfile()
dir.create(tmp1)
dir.create(tmp2)

Install the first version into tmp1.

.libPaths(tmp1)
install.packages("DBI", type = "source")

Install the second version into tmp2.

.libPaths(tmp2)
install.packages("http://cran.rstudio.com/src/contrib/Archive/DBI/DBI_0.2-7.tar.gz",
    repos=NULL, type="source")

Now add both temporary directories to the search path, and see what versions we have.

.libPaths(c(tmp1, tmp2))
package_versions("DBI")

Load both versions.

camo("DBI", "0.2-7")
camo("DBI", "0.3.0")
loadedNamespaces() %>% grep(pattern = "^DBI", value = TRUE)

See the functions in both versions.

ls(asNamespace("DBI@0.3.0"))
ls(asNamespace("DBI@0.2-7"))


metacran/camo documentation built on May 22, 2019, 6:54 p.m.