Tweet about this on TwitterShare on LinkedInShare on FacebookGoogle+Share on StumbleUponEmail to someone

This is a very quick post just to share a quick tip on how to add non overlapping labels to a scatterplot in ggplot using a great package called directlabels. The trick is to make each point a single member group using an aesthetic like colour and then apply the direct.label function with the first.qp method. Some example code and output is below

library(ggplot2)
library(directlabels)
x<-runif(10)
y<-rnorm(10)
z<-as.character(midwest$county[1:10])
q<-qplot(x,y)+geom_point(aes(colour=z))
direct.label(q, first.qp)

If there are better ways then I’d love to know but it works well for me and has the added advantage that the labels are matched to the points by colour.

EC2 Tutorials: rJava – annoying enough to have its own blog post

Tweet about this on TwitterShare on LinkedInShare on FacebookGoogle+Share on StumbleUponEmail to someone

One of the most frustrating items that I’ve been trying to install on my EC2 instance is rJava. Its an R package that lots of other packages have as a dependency, including glmulti and MongoDB.

I’ve spent a fair few hours trying to get this installed, constantly receiving the error message:

configure: error: Java Development Kit (JDK) is missing or not registered in R
Make sure R is configured with full Java support (including JDK). Run
R CMD javareconf
as root to add Java support to R.

I dutifully ran the recommended line of code (several times, as root, as ec2-user, etc. etc. etc.)

About half way through this journey I checked with another EC2 instance with R installed and received the same error, which at least reassured me that I had not completely screwed up my R installation, so kept persevering.

My main line of inquiry was checking that the JDK was installed properly – from my limited Linux experience it looked OK, but I also came across some forum posts

Cutting a long story short, I finally came across this post and found this beautiful line of code, which hopefully will sort out your problems (or at least check off the problem that I had):

yum install java-1.6.0-openjdk-devel

Machine Learning and Analytics based in London, UK