Closed teunbrand closed 4 years ago
This is now possible in the dev branch:
clust <- hclust(dist(USArrests), "ave")
df <- cbind(State = rownames(USArrests),
USArrests)
df <- reshape2::melt(df, id.vars = "State")
ggplot(df, aes(variable, State, fill = value)) +
geom_raster() +
scale_y_dendrogram(hclust = clust)
This relies on the ggplot2 v3.3.0 release candidate for the extendible axes system, so Travis CI will fail untill v3.3.0 is on CRAN.
For discrete data, implement a
scale_x_dendrogram
/scale_y_dendrogram
function that take ahclust
-class object compatible with the discrete values of the data, reorders the axis according to the dendrogram and draws the tree as part of the axis.Potential later addition could be to dynamically generate the hclust data given the data, instead of having to rely on the user to supply it.