This is a follow on from the previous post, with updated code.
There was an argument ‘groups’ in the ggplot(…) line of the code that was working but is now no longer working with the updated version of R/ggplot2 (I don’t know the full ins and outs of this sorry). So code is fixed and available below.
Most up-to-date code available here: http://pastebin.com/FjkWnCWm
Code originally included in this post: http://pastebin.com/yRmuZtPG