diff --git a/.Rbuildignore b/.Rbuildignore index 6ab23bf..ee70507 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -3,3 +3,5 @@ LICENSE.md .travis.yml ^.*\.Rproj$ ^\.Rproj\.user$ +^docs$ +^_pkgdown\.yml$ diff --git a/DESCRIPTION b/DESCRIPTION index 7400fa9..adebac7 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -12,8 +12,8 @@ Description: Makes it possible to create an internally consistent subset. The user can then install packages from this repository directly, rather than from CRAN. This is useful in production settings, e.g. server behind a firewall, or remote locations with slow (or zero) Internet access. -Date: 2017-11-15 -Version: 0.2.10.9000 +Date: 2017-12-19 +Version: 0.2.11.9000 URL: https://github.com/andrie/miniCRAN BugReports: https://github.com/andrie/miniCRAN/issues SystemRequirements: Imports the `curl` and `XML` packages. These have system diff --git a/NEWS b/NEWS index b32550a..ee43d11 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,11 @@ +miniCRAN v0.2.11.9000 (Release date: in development) +================ + +New features: + +* Used `pkgdown` to build documentation site + + miniCRAN v0.2.10.9000 ===================== diff --git a/README.md b/README.md index 643ed88..22c49ed 100644 --- a/README.md +++ b/README.md @@ -11,16 +11,18 @@ Create a mini version of CRAN containing only selected packages ## Introduction -At the end of 2014, CRAN consisted of more than 6,000 packages. Many organisations need to maintain a private mirror of CRAN, but with only a subset of packages that are relevant to them. +At the end of 2014, CRAN consisted of more than 6,000 packages. By then end of 2017, the number of packages doubled to more than 12,000. Many organisations need to maintain a private mirror of CRAN, but with only a subset of packages that are relevant to them. -`miniCRAN` makes it possible to create an internally consistent repository consisting of selected packages from CRAN-like repositories. The user specifies a set of desired packages, and miniCRAN recursively reads the dependency tree for these packages, then downloads only this subset. +The `miniCRAN` package makes it possible to create an internally consistent repository consisting of selected packages from CRAN-like repositories. The user specifies a set of desired packages, and `miniCRAN` recursively reads the dependency tree for these packages, then downloads only this subset. ## Important functions: -* Find package dependencies: `pkgDep()` -* Make repository (with or without downloading packages): `makeRepo()` -* Add additonal packages (and their dependencies) to existing repository: `addPackage()` -* Update the versions of packages currently in the repository: `updatePackages()` +Function | Use it for +-------------- | ------------------------------------------ +`pkgDep()` | Find package dependencies +`makeRepo()` | Make repository (with or without downloading packages) +`addPackage()` | Add additonal packages (and their dependencies) to existing repository +`updatePackages()` | Update the versions of packages currently in the repository ## Installation: @@ -33,7 +35,7 @@ library("miniCRAN") ### Development version -Get the latest stable development version from github: +Get the latest development version from github: ```r # Use `devtools` to install directly from github @@ -43,19 +45,19 @@ install_github("andrie/miniCRAN") ### System requirements -The `miniCRAN` package itself doesn't introduce any system dependencies. However, the package imports [`curl`](https://cran.r-project.org/package=curl) and `XML` packages. These have system requirements on `libxml2-devel`, `libcurl-devel` and `openssl-devel`. +The `miniCRAN` package itself doesn't introduce any system dependencies. However, the package imports the [`curl`](https://cran.r-project.org/package=curl) and [`XML`](https://cran.r-project.org/package=XML) packages. These have system requirements on `libxml2-devel`, `libcurl-devel` and `openssl-devel`. -On systems with the `rpm` package manager (Red Hat, CentOS) try: +* On systems with the `rpm` package manager (Red Hat, CentOS) try: -```bash -yum install libcurl-devel libxml2-devel openssl-devel -``` + ```sh + yum install libcurl-devel libxml2-devel openssl-devel + ``` -On systems with the `aptitude` package manager (Debian, Ubuntu) try: +* On systems with the `aptitude` package manager (Debian, Ubuntu) try: -```bash -apt-get install libcurl4-openssl-dev libxml2-devel openssl-devel -``` + ```sh + apt-get install libcurl4-openssl-dev libxml2-devel openssl-devel + ``` ## Example: @@ -65,7 +67,7 @@ apt-get install libcurl4-openssl-dev libxml2-devel openssl-devel library("miniCRAN") pkgs <- c("ggplot2", "plyr", "reshape2") -makeRepo(pkgDep(pkgs), path=file.path(tempdir(), "miniCRAN"), download=TRUE) +makeRepo(pkgDep(pkgs), path = file.path(tempdir(), "miniCRAN")) ``` ## Supported by Microsoft diff --git a/inst/doc/miniCRAN-dependency-graph.html b/inst/doc/miniCRAN-dependency-graph.html index ac50e16..dff8732 100644 --- a/inst/doc/miniCRAN-dependency-graph.html +++ b/inst/doc/miniCRAN-dependency-graph.html @@ -8,297 +8,71 @@ + - +
The miniCRAN
package exposes two functions that provide information about dependencies:
chron
Suggests the packages scales and ggplot2. This means that chron
uses some functions from these packages in examples or in its vignettes. However, these functions are not necessary to use chron
chron
Enhances the package zoo
, meaning that it adds something to zoo
packages. These enhancements are made available to you if you have zoo
installed.
The function pkgDep()
exposes not only these dependencies, but also all recursive dependencies. In other words, it answers the question which packages need to be installed to satisfy all dependencies of dependencies.
This means that the algorithm is as follows:
@@ -320,25 +94,25 @@The resulting list of packages should then contain the complete list necessary to satisfy all dependencies. In code:
-library("miniCRAN")
-tags <- "chron"
-pkgDep(tags, availPkgs = cranJuly2014)
+library("miniCRAN")
tags <- "chron"
+pkgDep(tags, availPkgs = cranJuly2014)
## [1] "chron" "RColorBrewer" "dichromat" "munsell"
## [5] "plyr" "labeling" "colorspace" "Rcpp"
## [9] "digest" "gtable" "reshape2" "scales"
## [13] "proto" "MASS" "stringr" "ggplot2"
To create an igraph plot of the dependencies, use the function makeDepGraph()
and plot the results:
dg <- makeDepGraph(tags, enhances = TRUE, availPkgs = cranJuly2014)
-set.seed(1)
-plot(dg, legendPosition = c(-1, 1), vertex.size = 20)
-
+dg <- makeDepGraph(tags, enhances = TRUE, availPkgs = cranJuly2014)
+set.seed(1)
+plot(dg, legendPosition = c(-1, 1), vertex.size = 20)
Note how the dependencies expand to zoo
(enhanced), scales
and ggplot
(suggested) and then recursively from there to get all the Imports
and LinkingTo
dependencies.
As a final example, create a dependency graph of seven very popular R packages:
-tags <- c("ggplot2", "data.table", "plyr", "knitr", "shiny", "xts", "lattice")
-pkgDep(tags, suggests = TRUE, enhances = FALSE, availPkgs = cranJuly2014)
+tags <- c("ggplot2", "data.table", "plyr", "knitr", "shiny", "xts", "lattice")
+pkgDep(tags, suggests = TRUE, enhances = FALSE, availPkgs = cranJuly2014)
## [1] "ggplot2" "data.table" "plyr" "knitr"
## [5] "shiny" "xts" "lattice" "digest"
## [9] "gtable" "reshape2" "scales" "proto"
@@ -359,30 +133,14 @@ An example with multiple input packages
## [69] "rgl" "XML" "RCurl" "Cairo"
## [73] "timeSeries" "tseries" "its" "fts"
## [77] "tis" "KernSmooth"
-dg <- makeDepGraph(tags, enhances = TRUE, availPkgs = cranJuly2014)
-set.seed(1)
-plot(dg, legendPosition = c(-1, -1), vertex.size = 10, cex = 0.7)
-
-
-
-
-
-
+dg <- makeDepGraph(tags, enhances = TRUE, availPkgs = cranJuly2014)
+set.seed(1)
+plot(dg, legendPosition = c(-1, -1), vertex.size = 10, cex = 0.7)
Start by creating the recursive dependency tree for your target packages.
For example, imagine a scenario where you want to create a repository that consists of the package foreach
and its dependencies.
Start by creating the dependency list:
-library("miniCRAN")
+library("miniCRAN")
-# use Revolution Analytics CRAN mirror
-revolution <- c(CRAN="http://cran.microsoft.com")
+# use Revolution Analytics CRAN mirror
+revolution <- c(CRAN = "http://cran.microsoft.com")
-# Specify list of packages to download
-pkgs <- c("foreach")
-pkgList <- pkgDep(pkgs, repos=revolution, type="source", suggests = FALSE, availPkgs = cranJuly2014)
-pkgList
+# Specify list of packages to download
+pkgs <- c("foreach")
+pkgList <- pkgDep(pkgs, repos = revolution, type = "source", suggests = FALSE,
+ availPkgs = cranJuly2014)
+pkgList
## [1] "foreach" "codetools" "iterators"
Next, create a repository with the function makeRepo()
. In this example, get the required files for source
packages as well as windows binaries:
-# Create temporary folder for miniCRAN
-dir.create(pth <- file.path(tempdir(), "miniCRAN"))
+# Create temporary folder for miniCRAN
+dir.create(pth <- file.path(tempdir(), "miniCRAN"))
-# Make repo for source and win.binary
-makeRepo(pkgList, path=pth, repos=revolution, type=c("source", "win.binary"))
+# Make repo for source and win.binary
+makeRepo(pkgList, path=pth, repos=revolution, type=c("source", "win.binary"))
Investigate the repository file structure:
-# List all files in miniCRAN
-list.files(pth, recursive=TRUE, full.names=FALSE)
+# List all files in miniCRAN
+list.files(pth, recursive = TRUE, full.names = FALSE)
Use pkgAvail
to list available packages in your repository:
-# Check for available packages
-pkgAvail(repos=pth, type="win.binary")[, c(1:3, 5)]
-
+# Check for available packages
+pkgAvail(repos = pth, type = "win.binary")[, c(1:3, 5)]
+
Install packages from your local repository
To install packages from a local repository, you need to use the URI convention file:///
to point to your file lcoation.
-install.packages(pkgs,
- repos = paste0("file:///", pth),
- type = "source")
-
-
+install.packages(pkgs,
+ repos = paste0("file:///", pth),
+ type = "source")
+
+
Adding packages to an existing miniCRAN repository
-
+
Adding new packages from CRAN
After creating a local miniCRAN repository, additional packages and their dependencies can easily be added. This mechanism can also be used to re-add an existing package to the miniCRAN repo.
-# Add new packages (from CRAN) to the miniCRAN repo
-addPackage("Matrix", path=pth, repos=revolution, type=c("source", "win.binary"))
-pkgAvail(repos=pth, type="win.binary")[, c(1:3, 5)]
+# Add new packages (from CRAN) to the miniCRAN repo
+addPackage("Matrix", path = pth, repos = revolution, type = c("source", "win.binary"))
+pkgAvail(repos = pth, type = "win.binary")[, c(1:3, 5)]
The value that is returned (invisibly) via addPackage
is the number of packages written to the index file, i.e., the total number of packages in the repo of that type.
-
-
+
+
Adding an older version of a package from CRAN
To add a specific version of a package from CRAN (or another CRAN-like repository), we can easily download the source packages from the CRAN archives. Dependencies for old package versions cannot be determined automatically and must be specified by the user.
Note: in order to to add binaries of older packages, you will need to download the source and build the binaries on the intended platform yourself. You will need the appropriate R development tools installed in order to build package binaries from source.
-# create a data frame with the package and version info
-oldVers <- data.frame(package=c("foreach", "codetools", "iterators"),
- version=c("1.4.0", "0.2-7", "1.0.5"),
- stringsAsFactors=FALSE)
-
-# download old source package version and create repo index
-addOldPackage(pkgList, path=pth, vers=oldVers$version, repos=revolution, type="source")
+# create a data frame with the package and version info
+oldVers <- data.frame(
+ package = c("foreach", "codetools", "iterators"),
+ version = c("1.4.0", "0.2-7", "1.0.5"),
+ stringsAsFactors = FALSE
+)
+
+# download old source package version and create repo index
+addOldPackage(pkgList, path = pth, vers = oldVers$version, repos = revolution, type = "source")
You will get a warning whenever there are multiple versions of a package saved in the repository. Currently, you need to manually remove duplicate versions before rebuilding the repository’s package index.
Note: This last step is important, otherwise you may end up with a repo in an inconsistent state.
-# List package versions in the miniCRAN repo (produces warning about duplicates)
-pkgVersionsSrc <- checkVersions(pkgList, path=pth, type="source")
-pkgVersionsBin <- checkVersions(pkgList, path=pth, type="win.binary")
+# List package versions in the miniCRAN repo (produces warning about duplicates)
+pkgVersionsSrc <- checkVersions(pkgList, path = pth, type = "source")
+pkgVersionsBin <- checkVersions(pkgList, path = pth, type = "win.binary")
-# After inspecting package versions, remove old versions
-basename(pkgVersionsSrc) # duplicate versions
-basename(pkgVersionsBin)
+# After inspecting package versions, remove old versions
+basename(pkgVersionsSrc) # duplicate versions
+basename(pkgVersionsBin)
-file.remove(pkgVersionsSrc[c(2,4,6)])
+file.remove(pkgVersionsSrc[c(2,4,6)])
-# rebuild the package index after removing duplicate package versions
-updateRepoIndex(pth, type=c("source", "win.binary"))
+# rebuild the package index after removing duplicate package versions
+updateRepoIndex(pth, type = c("source", "win.binary"))
To see the updated list of packages available in the miniCRAN repo:
-pkgAvail(pth, type="source")[, c(1:3, 5)] # contains the old versions
-pkgAvail(pth, type="win.binary")[, c(1:3, 5)] # contains the current versions
-
-
+pkgAvail(pth, type = "source")[, c(1:3, 5)] # contains the old versions
+pkgAvail(pth, type = "win.binary")[, c(1:3, 5)] # contains the current versions
+
+
Adding packages from other sources
This feature will be implemented in a future release.
-
-
-
+
+
+
Updating the packages in a miniCRAN repository
Checking for updated versions of the packages currently stored in the miniCRAN repository:
-# Check if updated packages are available
-oldPackages(path=pth, repos=revolution, type="source")[, 1:3] # should need update
-oldPackages(path=pth, repos=revolution, type="win.binary")[, 1:3] # should be current
-Update the versions of the packages currently stored in the miniCRAN repository. By default, a prompt is given to confirm the update for each package. This prompt can be suppressed using ask=FALSE
, which will update all packages. Be careful using this option if you want to keep certain packages at an older version.
-# Update available packages
-updatePackages(path=pth, repos=revolution, type="source", ask=FALSE) # should need update
-updatePackages(path=pth, repos=revolution, type="win.binary", ask=FALSE) # should be current
-
-
-
-
-
+# Check if updated packages are available
+oldPackages(path = pth, repos = revolution, type = "source")[, 1:3] # should need update
+oldPackages(path = pth, repos = revolution, type = "win.binary")[, 1:3] # should be current
+Update the versions of the packages currently stored in the miniCRAN repository. By default, a prompt is given to confirm the update for each package. This prompt can be suppressed using ask = FALSE
, which will update all packages. Be careful using this option if you want to keep certain packages at an older version.
+# Update available packages
+updatePackages(path = pth, repos = revolution, type = "source", ask = FALSE) # should need update
+updatePackages(path = pth, repos = revolution, type = "win.binary", ask = FALSE) # should be current
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Using repositories other than CRAN with miniCRAN
Andrie de Vries
-October 21, 2017
+December 19, 2017
-
-
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()
:
-# 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]
-}
-
+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)
-
-
+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:
-revoStable <- "http://packages.revolutionanalytics.com/cran/3.1/stable"
-index(revoStable)
+revoStable <- "http://packages.revolutionanalytics.com/cran/3.1/stable"
+index(revoStable)
-revoMirror <- "http://cran.revolutionanalytics.com"
-index(revoMirror)
-
-
+revoMirror <- "http://cran.revolutionanalytics.com"
+index(revoMirror)
+
+
Using R-forge
R-forge has CRAN-like structure:
-rforge <- "http://r-forge.r-project.org"
-index(rforge)
-
-
+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:
-bioc <- local({
- env <- new.env()
- on.exit(rm(env))
- evalq(source("http://bioconductor.org/biocLite.R", local=TRUE), env)
- biocinstallRepos()
+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))]
+bioc[grep("BioC", names(bioc))]
-index(bioc["BioCsoft"])
-
-
-
-
-
+index(bioc["BioCsoft"])
-
-