If you are interested in some of the raw code, I have linked a version of the R file which has been edited to preserve client privacy HERE