2014年10月21日星期二

r plot, phangorn package

In R in Ubuntu 12.04,

when you install and use the "phangorn" package, you might get such error:

install.packages("phangorn")
library(phangorn)

configure: error: missing required header GL/gl.h
ERROR: configuration failed for package ‘rgl

normally means you haven't installed the -dev version of a package, in this case GL, and you will need to install: 

sudo apt-get install mesa-common-dev
sudo apt-get install libglu1-mesa-dev 
sudo apt-get install freeglut3-dev 
sudo apt-get install mesa-common-dev

You might get the following error later (in R) because of a tcl b**/gripe/compliant: Error in structure(.External(.C_dotTcl, ...), class = "tclObj") : [tcl] can't find package BWidget.
To fix this problem, if you have it:
install at the regular terminal:
sudo apt-get install bwidget

R plot, tricky input of cex

In R plot,

For example:

plot(...... pch=20, cex=0.5)

Here, the 'cex' controls the size of the symbol. But if this value is passed in from another variable or from command line, it has to be converted to integer or numeric value (the numeric value is better).

For example:

my.cex.size = as.numeric(args[1])
plot(...... pch=20, cex=my.cex.size)