Skip to content

Instantly share code, notes, and snippets.

@coppeliaMLA
Created July 8, 2014 16:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save coppeliaMLA/35e51f15d6abba0ec49f to your computer and use it in GitHub Desktop.
Save coppeliaMLA/35e51f15d6abba0ec49f to your computer and use it in GitHub Desktop.
Buster Example 2
#Another simple test
x.1<-rnorm(50, 10, 3)
y.1<-rnorm(50, 10, 3)
x.2<-rnorm(50, 20, 3)
y.2<-rnorm(50, 10, 3)
x.3<-rnorm(50, 13, 3)
y.3<-rnorm(50, 20, 3)
test.data<-data.frame(group=rep(1:3, each=50), x=c(x.1, x.2, x.3), y=c(y.1, y.2, y.3))
names<-c(paste0("group 1: ", 1:50), paste0("group 2: ", 1:50), paste0("group 3: ", 1:50))
rownames(test.data)<-names
dist<-dist(test.data[,-1])
bhc<-buster(dist, n=200, k=3, size=0.66, method='ward', pct.exc=0.1)
plot(bhc)
#Append the assigned clusters
graph.data<-cbind(test.data, bhc$obs.eval[order(bhc$obs.eval$obs.ind, decreasing=FALSE),])
plot(graph.data$x, graph.data$y, xlim=c(0,30), ylim=c(0, 30), pch = graph.data$group, col=graph.data$cluster+1)
max.co<-bhc$obs.eval$max.co[order(bhc$obs.eval$obs.ind)]
alpha<-(max.co-min(max.co))/(max(max.co)-min(max.co))
cols <- hsv(0,0,0,alpha)
plot(graph.data$x, graph.data$y, xlim=c(0,30), ylim=c(0, 30), pch = 19, col=cols)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment