Introducing drat: Lightweight R Repositories
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
A new package of mine just got to CRAN in its very first version 0.0.1: drat. Its name stands for drat R Archive Template, and an introduction is provided at the drat page, the GitHub repository, and below.
drat builds on a core strength of R: the ability to query multiple repositories. Just how one could always query, say, CRAN, BioConductor and OmegaHat—one can now adds drats of one or more other developers with ease. drat also builds on a core strength of GitHub. Every user automagically has a corresponding github.io
address, and by appending drat
we are getting a standardized URL.
drat combines both strengths. So after an initial install.packages("drat")
to get drat, you can just do either one of
library(drat) addRepo("eddelbuettel")
or equally
drat:::add("eddelbuettel")
to register my drat. Now install.packages()
will work using this new drat, as will update.packages()
. The fact that the update mechanism works is a key strength: not only can you get a package, but you can gets its updates once its author replaces them into his drat.
How does one do that? Easy! For a package foo_0.1.0.tar.gz
we do
library(drat) insertPackage("foo_0.1.0.tar.gz")
The default git repository locally is taken as the default ~/git/drat/
but can be overriden as both a local default (via options()
) or directly on the command-line. Note that this also assumes that you a) have a gh-pages
branch and b) have that branch as the currently active branch. Automating this / testing for this is left for a subsequent release. Also available is an alternative unexported short-hand function:
drat:::insert("foo_0.1.0.tar.gz", "/opt/myWork/git")
show here with the alternate use case of a local fileshare you can copy into and query from—something we do at work where we share packages only locally.
The easiest way to obtain the corresponding file system layout may be to just fork the drat repository.
So that is it. Two exported functions, and two unexported (potentially name-clobbering) shorthands. Now drat away!
Courtesy of CRANberries, there is also a copy of the DESCRIPTION
file for this initial release. More detailed information is on the drat page.
This post by Dirk Eddelbuettel originated on his Thinking inside the box blog. Please report excessive re-aggregation in third-party for-profit settings.
R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.