I'm attempting to visualize a cluster tree using this awesome D3 layout! However, it needs data in JSON format - how do I go from a hclust-object
in R to a hierarchical JSON structure?
set.seed(123)
m <- matrix(runif(100), nrow=10)
cl <- hclust(dist(m))
plot(cl)
My googling turned up this hclustToTree function which returns a list that looks promising - but I don't really know where to go from there. Any advice would be much appreciated.
halfway <- hclustToTree(cl)
You're almost there:
jsonTree <- toJSON(halfway) # part of the RJSONIO library