Skip to content

Instantly share code, notes, and snippets.

@jamesthomson
Created August 16, 2014 11:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jamesthomson/176e0a24c5496b2e99b5 to your computer and use it in GitHub Desktop.
Save jamesthomson/176e0a24c5496b2e99b5 to your computer and use it in GitHub Desktop.
data(counties)
JSON<-jsonNestedData(structure=counties[,1:3], values=counties[,4], top_label="UK")
D3Tree(JSON, file_out="Tree.html")
hc.ave <- hclust(dist(USArrests), "ave")
hc.single <- hclust(dist(USArrests), "single")
hc.ward <- hclust(dist(USArrests), "ward.D")
cut.ave<-cutree(hc.ave, k=6)
cut.single<-cutree(hc.single, k=6)
cut.ward<-cutree(hc.ward, k=6)
ClustComp<-data.frame(States=rownames(USArrests), ave=as.vector(cut.ave),single=as.vector(cut.single),ward=as.vector(cut.ward))
JSON<-jsonCompare(ClustComp)
D3Sankey(JSON, file_out="/Users/home/Documents/R_Projects/Sankey.html")
hc <- hclust(dist(USArrests), "ave")
plot(hc)
JSON<-jsonHC(hc)
D3Dendro(JSON, file_out="/Users/home/Documents/R_Projects/USArrests_Dendo.html")
data(celebs)
colnames(celebs$relationships)<-c('source', 'target')
colnames(celebs$celebs)<-c('name', 'group')
JSON<-jsonNodesLinks(celebs$celebs, celebs$relationships)
D3Force(JSON, file_out="/Users/home/Documents/R_Projects/Force.html")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment