[Rd] Near-perl-like levels of obfuscation

Douglas Bates bates at stat.wisc.edu
Sun Mar 21 15:32:39 CET 2004

Dirk Eddelbuettel and Albrecht Gephardt have created many Debian
packages of R packages from CRAN and other archives.

I wanted to install all these Debian packages on a machine running the
Debian testing distribution.  One way to do this is to search (using
the apt-cache program) for all Debian package names that begin with
'r-', extract the package name, and concatenate all those names as
arguments to the apt-get program.  (As more Debian packages are
produced there will likely need to be a call to xargs in there somewhere.)

The output of the first program is

$ apt-cache search --names-only '^r-'
r-cran-boot - GNU R package for bootstrapping functions from Davison and Hinkley
r-cran-car - GNU R Companion to Applied Regression by John Fox
r-cran-coda - Output analysis and diagnostics for MCMC simulations in R
r-cran-dbi - database interface for R
r-cran-design - GNU R regression modeling strategies tools by Frank Harrell
r-cran-effects - GNU R graphical and tabular effects display for glm models
r-cran-gtkdevice - GNU R Gtk device driver package
r-cran-hmisc - GNU R miscellaneous functions by Frank Harrell
r-cran-lmtest - GNU R package for diagnostic checking in linear models
r-cran-nlme - GNU R package for (non-)linear mixed effects models
r-cran-rcmdr - GNU R platform-independent basic-statistics GUI
r-cran-rmysql - MySQL interface for R
r-cran-rodbc - GNU R package for ODBC database access
r-cran-rquantlib - GNU R package interfacing the QuantLib finance library
r-cran-statdataml - XML based data exchange format (R library)
r-cran-tkrplot - GNU R embedded Tk plotting device package
r-cran-tseries - GNU R package for time-series analysis and comp. finance
r-cran-xml - An XML package for the R language
r-omegahat-rgtk - GNU R binding for Gtk
r-omegahat-ggobi - GNU R package for the GGobi data visualization system
r-cran-mapproj - GNU R support for cartographic projections of map data
r-base - GNU R statistical computing language and environment
r-base-core - GNU R core of statistical computing language and environment
r-base-dev - GNU R installation of auxiliary GNU R packages
r-base-html - GNU R html docs for statistical computing system functions
r-base-latex - GNU R LaTeX docs for statistical computing system functions
r-cran-abind - GNU R abind multi-dimensional array combination function
r-cran-cluster - GNU R package for cluster analysis by Rousseeuw et al
r-cran-foreign - GNU R package to read / write data from other statistical systems
r-cran-its - GNU R package for handling irregular time series
r-cran-kernsmooth - GNU R package for kernel smoothing and density estimation
r-cran-lattice - GNU R package for 'Trellis' graphics
r-cran-mapdata - GNU R support for producing geographic maps (supplemental data)
r-cran-maps - GNU R support for producing geographic maps
r-cran-mcmcpack - routines for Markov Chain Monte Carlo model estimation in R
r-cran-mgcv - GNU R package for multiple parameter smoothing estimation
r-cran-multcomp - GNU R package for multiple comparison procedures
r-cran-mvtnorm - GNU R package to compute multivariate Normal and T distributions
r-cran-qtl - [Biology] GNU R package for genetic marker linkage analysis
r-cran-relimp - GNU R package for inference on relative importance of regressors
r-cran-rpart - GNU R package for recursive partitioning and regression trees
r-cran-survival - GNU R package for survival analysis
r-cran-vr - GNU R package accompanying the Venables and Ripley book on S
r-doc-html - GNU R html manuals for statistical computing system
r-doc-info - GNU R info manuals statistical computing system
r-doc-pdf - GNU R pdf manuals for statistical computing system
r-gnome - GNU R Gnome gui for statistical computing system
r-mathlib - GNU R standalone mathematics library
r-noncran-lindsey - GNU R libraries contributed by Jim and Patrick Lindsey
r-recommended - GNU R collection of recommended packages [metapackage]

To provide only the names as arguments to apt-get install I need to
split the returned strings on blanks and extract the first component.
I'm sure it would be trivial to write a call to perl to do this except
that my perl skills are very rusty and I didn't want to wade through
the documentation just to find out how to do this.  Also, as Kurt
Hornik once remarked, "I don't tend to write in scripting languages
like perl and python as much now because I know another powerful
language quite well".

Here's a solution from within R (and this worked within ESS in emacs,
which I found quite impressive).

system(paste("sudo apt-get install -qq", paste(unlist(lapply(
             strsplit(readLines(pipe("apt-cache search --names-only '^r-'")),
                      " "), "[", 1)), collapse = " ")))

BTW, an administrators of a Debian installation does not need to run
this command frequently.  Running

apt-get update
apt-get upgrade

upgrades to new versions of these packages.  This call only needs to
be run when you wish to detect newly available Debian packages of R

Thanks to Dirk for creating the majority of those Debian packages.

More information about the R-devel mailing list