The switchr package

Gabriel Becker

Genentech, Inc

1 Package versions matter

1.1 Reproducing results

  • Use same version as original author(s)

1.2 Developing packages

  • Program against latest/devel versions of dependencies

1.3 Collaboration

  • Have single set of versions used by all participants

2 Packages live in different places

2.1 Github

2.2 Package repositories

2.3 CRAN Archive

2.4 SCM commit history

3 What do we need?

3.1 Install the versions we need

  • on command
  • directly from where they live

3.2 Distinct, side-by-side package libraries

  • Don't want to clobber our main install to reproduce old result
  • Development and analysis

3.3 Recreate others' environments

3.4 Publish our environments

  • So that others can recreate them

4 switchr does that

5 Package manifests

5.1 Generalized Package repository

  • List of packages
    • where their source lives
    • info necessary to retrieve them
  • Optional version restrictions

6 And now the 'main' event

6.1 Creating a new library

switchTo("mynewlib")
Switched to the 'mynewlib' computing environment. 29 packages are currently available. Packages installed in your site library ARE suppressed.
 To switch back to your previous environment type switchBack()

6.2 Switching between libraries

switchBack()
Reverted to the 'recreate' computing environment. 33 packages are currently available. Packages installed in your site library ARE suppressed.
 To switch back to your previous environment type switchBack()
switchTo("mynewlib")
Switched to the 'mynewlib' computing environment. 29 packages are currently available. Packages installed in your site library ARE suppressed.
 To switch back to your previous environment type switchBack()

6.3 Creating a manifest

man = GithubManifest("gmbecker/fastdigest", "gmbecker/RCacheSuite",
    "duncantl/CodeDepends")
man
A package manifest (PkgManifest object)

Contains 3 packages and 5 dependency repositories

Packages:
         name type
1  fastdigest  git
2 RCacheSuite  git
3 CodeDepends  git

6.4 Installing from a manifest

install_packages("RCacheSuite", man)
head(installed.packages()[,c("Package", "Version")], 4)
            Package       Version   
CodeDepends "CodeDepends" "0.3-5"   
fastdigest  "fastdigest"  "0.5-1"   
RCacheSuite "RCacheSuite" "0.0-1"   
XML         "XML"         "3.98-1.1"

6.5 Generating a manifest from a library

man2 = libManifest()
man2
A seeding manifest (SessionManifest object)

Describes a cohort of 4 package versions. 
4 packages are listed in the underlying package manifest

Package versions:
         name  version
1 CodeDepends    0.3-5
2  fastdigest    0.5-1
3 RCacheSuite    0.0-1
4         XML 3.98-1.1

6.6 Generating a library from a manifest

switchTo("recreate", seed = man2)

6.7 Publishing a manifest to a Gist

library(switchrGist)
publishManifest(man, Gist())

6.8 Traveling back in time

man3.0 = rVersionManifest("3.0.0")
man3.0
 "..."       "..."    
5005 "zmatrix"   "tarball"
5006 "zoeppritz" "tarball"
5007 "zoo"       "tarball"
5008 "zooimage"  "tarball"
5009 "zyp"       "tarball"

7 The code

http://github.com/gmbecker/switchr http://github.com/gmbecker/switchrGist