Wednesday, November 10, 2010

System-wide installation of an R package from CRAN

Installing 'brainwaver'

Run R as root (!)

$ sudo R

And then at the R prompt, type:

> install.packages('brainwaver', dep = TRUE)

This should also pull in the waveslim package on which brainwaver depends.

It will pop up a window with a list of mirrors to download from. I chose London.

Now get out of R before you forget that you're running as root and do serious damage to your system.

You can verify that it's worked by trying

> help(brain)

at the prompt.

When things go wrong.

I next tried to install odfWeave in the same manner.

All seemed well, and it pulled in a package XML as a dependency, but while installing XML,
there was a bunch of output, which looked like a configure script running.

Things obviously went wrong at about this point.


checking for xml2-config... no
Cannot find xml2-config
ERROR: configuration failed for package ‘XML’
* removing ‘/usr/local/lib/R/site-library/XML’

Luckily typing xml2-config at the prompt gave:

$ xml2-config
The program 'xml2-config' is currently not installed.  You can install it by typing:
$ sudo apt-get install libxml2-dev

So I installed libxml2-dev as suggested, and then Bob was my uncle.