Tag Archives: r

How to list all installed R-packages

I don’t use R, and I don’t know much about it. However, I maintain R installation on Linux machines at work.

Today, I learned a new trick of listing all installed R-packages. Here it is:

ip = as.data.frame(installed.packages()[,c(1,3:4)])
ip = ip[is.na(ip$Priority),1:2,drop=FALSE]
ip

And here is the sample output:

Type 'license()' or 'licence()' for distribution details.

  Natural language support but running in an English locale

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> ip = as.data.frame(installed.packages()[,c(1,3:4)])
> ip = ip[is.na(ip$Priority),1:2,drop=FALSE]
> ip
                  Package   Version
akima               akima    0.5-12
alr3                 alr3     2.0.5
BRugs               BRugs     0.8-6
car                   car     2.1-2
coda                 coda    0.18-1
colorspace     colorspace     1.2-6
DEoptimR         DEoptimR     1.0-5
dichromat       dichromat     2.0-0
digest             digest     0.6.9
distillery     distillery     1.0-2
extRemes         extRemes     2.0-7
fields             fields     8.4-1
...

I don’t have time to explain what each line does. If you’re curious, just check out the references below:

YUM what provides this file, huh?

This post is primarily written to remind myself, an Ubuntu user, to figure out how to find what RPM package provides a file — for example a header file.

Today, I’m trying to compile and install R 3.1.3 on CentOS 6 from source code. This R installation is one of the requirements to install Tessera stack. The instruction from the installation page is:

sudo yum install blas blas-devel lapack lapack-devel
wget http://cran.r-project.org/src/base/R-3/R-3.1.3.tar.gz
tar zxvf R-3.1.3.tar.gz
cd R-3.1.3
./configure --with-blas --with-lapack --with-x --enable-R-shlib
make
sudo make install

Unfortunately, the process failed with ./configure with the complain about missing readline library. To fix it, I had to install readline-devel package.

sudo yum install blas blas-devel lapack lapack-devel readline-devel

After that, I re-ran the ./configure. This time it still complains that some X11 header files are missing, one of them is: Intrinsic.h.

Let’s find out what package provides this file:

# yum provides \*/Intrinsic.h
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: centos.mirror.digitalpacific.com.au
 * extras: centos.mirror.digitalpacific.com.au
 * updates: centos.mirror.digitalpacific.com.au
libXt-devel-1.1.4-6.1.el6.x86_64 : X.Org X11 libXt development package
Repo        : base
Matched from:
Filename    : /usr/include/X11/Intrinsic.h

libXt-devel-1.1.4-6.1.el6.i686 : X.Org X11 libXt development package
Repo        : base
Matched from:
Filename    : /usr/include/X11/Intrinsic.h

Ah ha, so let’s install libXt-devel. This time, I was able to configure, make and install the R.

References: https://www.centos.org/forums/viewtopic.php?t=5933

R-tip: List installed R packages

> rownames(installed.packages())
 [1] "bitops"     "manipulate" "RCurl"      "rgl"        "rstudio"   
 [6] "scrapeR"    "XML"        "base"       "boot"       "class"     
[11] "cluster"    "codetools"  "compiler"   "datasets"   "foreign"   
[16] "graphics"   "grDevices"  "grid"       "KernSmooth" "lattice"   
[21] "MASS"       "Matrix"     "methods"    "mgcv"       "nlme"      
[26] "nnet"       "parallel"   "rpart"      "spatial"    "splines"   
[31] "stats"      "stats4"     "survival"   "tcltk"      "tools"     
[36] "utils"     
>