Friday, January 7, 2011

r-project / r-cran and install.packages()

My version of the excellent statistics and mathematics package from, is now 2.11, having updated to Debian Squeeze.

( The major work from Google Summer of code 2010 is probably in 2.12 released December 2010 )

I tend to install just the minimal r-project packages and then immediately add rgl for pretty plot3d.

But before rushing into install.packages("rgl"), perhaps I should check where exactly the install code will end up.

looks to me as if /usr/local/lib/R/site-library might be the destination (set in R_LIBS_SITE), so let us see...

install.packages("rgl") pops up a country ordered list, for you to select a mirror for the install

Interesting to see the number of mirrors, 5 for Germany, and 5 for Canada, and I should scroll down to below Taiwan to pick my country.

( Above confirms my guesswork that any install.packages on my system defaults to /usr/local/lib/R/site-library )

Now what happens next, really changes the course of this read on.

The install.packages() command failed as it could not locate GL/gl.h or GL/glu.h, and here I consulted my laptop.
The laptop already has rgl installed and working, so I used find and dpkg, and discovered my silly mistake.

There is already a debian package in squeeze named 'r-cran-rgl' which will do all the hard work for me :)

apt-get install r-cran-rgl 

will replace the manual install.packages() method and get you into plot3d() in no time at all :)

( for those who are interested in where GL/glu.h lives, try libglu1-mesa-dev in support of manual install of rgl )

The plot3d() function in rgl allows you 'drag to spin' functionality so you can rotate, and examine the points from any angle you choose.

In the above I have dragged the back round to the front so zero is away from you, and hopefully, you can just make out the points curving up towards point (5,5,60) which is the end of the curve.

Some further illustrations of what rgl can do can be found on in section 'Spinning 3D Scatterplots'.

Further reading and links:
For technical folks you really want more packages and are interested in install.packages(), here is the function definition with arguments:

No comments:

Post a Comment