---
title:  "Using repositories other than CRAN with miniCRAN"
author: "Andrie de Vries"
date:   "`r as.character(format(Sys.Date(), format='%B %d, %Y'))`"
output:
  html_document:
    self_contained: yes
    toc: yes
vignette: >
  %\VignetteEngine{knitr::rmarkdown}
  %\VignetteIndexEntry{Using repositories other than CRAN with miniCRAN}
  %\VignettePackage{miniCRAN}
  %\VignetteKeyword{miniCRAN}
  %\usepackage[utf8]{inputenc}
---

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 simplify the code to show the salient features, we use a little helper function, `index()` that is a simple wrapper around `available.packages()`:


```{r setup}
# 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:

```{r CRAN, eval=FALSE}
CRAN <- "http://cran.r-project.org"
index(CRAN)
```


## Using a different mirror

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

```{r revo, eval=FALSE}
revoStable <- "http://packages.revolutionanalytics.com/cran/3.1/stable"
index(revoStable)
 
revoMirror <- "http://cran.revolutionanalytics.com"
index(revoMirror)
```

## Using R-forge

R-forge has CRAN-like structure:

```{r rforge, eval=FALSE}
rforge <- "http://r-forge.r-project.org"
index(rforge)
```

## Using BioConductor

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

```{r bioc, eval=FALSE}
bioc <- local({
  env <- new.env()
  on.exit(rm(env))
  evalq(source("http://bioconductor.org/biocLite.R", local=TRUE), env)
  biocinstallRepos()
})
 
bioc
bioc[grep("BioC", names(bioc))]
 
 
index(bioc["BioCsoft"])
```
