Using repositories other than CRAN with miniCRAN

Although the package name miniCRAN seems to indicate you can only use CRAN as a repository, you can in fact use any CRAN-like repository.

This vignette contains some examples of how to refer to different package repositories, including CRAN, alternative mirrors of CRAN, R-Forge as well as BioConductor.

To make simplify the code to show the salient features, we use a little helper function, index() that is a simple wrapper around available.packages():

# Wrapper around available.packages ---------------------------------------

index <- function(url, type="source", filters=NULL, head=5, cols=c("Package", "Version")){
  contribUrl <- contrib.url(url, type=type)
  p <- available.packages(contribUrl, type=type, filters=filters)
  p[1:head, cols]
}

Using CRAN

The URL for the master mirror in Austria:

CRAN <- "http://cran.r-project.org"
index(CRAN)
##             Package       Version
## A3          "A3"          "0.9.2"
## abc         "abc"         "2.0"  
## ABCanalysis "ABCanalysis" "1.0"  
## abcdeFBA    "abcdeFBA"    "0.4"  
## ABCExtremes "ABCExtremes" "1.0"

Using a different mirror

You can also point to any other mirror, for example the stable version hosted by Revolution Analytics:

revoStable <- "http://packages.revolutionanalytics.com/cran/3.1/stable"
index(revoStable)
##             Package       Version  
## A3          "A3"          "0.9.2"  
## abc         "abc"         "2.0"    
## abcdeFBA    "abcdeFBA"    "0.4"    
## ABCExtremes "ABCExtremes" "1.0"    
## ABCoptim    "ABCoptim"    "0.13.11"
revoMirror <- "http://cran.revolutionanalytics.com"
index(revoMirror)
##             Package       Version
## A3          "A3"          "0.9.2"
## abc         "abc"         "2.0"  
## ABCanalysis "ABCanalysis" "1.0"  
## abcdeFBA    "abcdeFBA"    "0.4"  
## ABCExtremes "ABCExtremes" "1.0"

Using R-forge

R-forge has CRAN-like structure:

rforge <- "http://r-forge.r-project.org"
index(rforge)
##             Package       Version 
## a4Core      "a4Core"      "0.99.0"
## a4Reporting "a4Reporting" "0.0-3" 
## abd         "abd"         "0.1-23"
## abind       "abind"       "1.4-3" 
## abmi        "abmi"        "0.1-0"

Using BioConductor

Although BioConductor has a different preferred install mechanism, the underlying repository structure is also CRAN-like:

bioc <- local({
  env <- new.env()
  on.exit(rm(env))
  evalq(source("http://bioconductor.org/biocLite.R", local=TRUE), env)
  biocinstallRepos()
})
## Bioconductor version 3.1 (BiocInstaller 1.17.6), ?biocLite for help
bioc
##                                               BioCsoft 
##            "http://bioconductor.org/packages/3.1/bioc" 
##                                                BioCann 
## "http://bioconductor.org/packages/3.1/data/annotation" 
##                                                BioCexp 
## "http://bioconductor.org/packages/3.1/data/experiment" 
##                                              BioCextra 
##           "http://bioconductor.org/packages/3.1/extra" 
##                                                   CRAN 
##                  "http://cran.revolutionanalytics.com" 
##                                              CRANextra 
##                   "http://www.stats.ox.ac.uk/pub/RWin"
bioc[grep("BioC", names(bioc))]
##                                               BioCsoft 
##            "http://bioconductor.org/packages/3.1/bioc" 
##                                                BioCann 
## "http://bioconductor.org/packages/3.1/data/annotation" 
##                                                BioCexp 
## "http://bioconductor.org/packages/3.1/data/experiment" 
##                                              BioCextra 
##           "http://bioconductor.org/packages/3.1/extra"
index(bioc["BioCsoft"])
##           Package     Version 
## a4        "a4"        "1.15.0"
## a4Base    "a4Base"    "1.15.0"
## a4Classif "a4Classif" "1.15.0"
## a4Core    "a4Core"    "1.15.0"
## a4Preproc "a4Preproc" "1.15.0"