Covert hclust objects to segments for use in ggplots

hclust_to_seg(hc, tree.dir = "down", dir.lims = c(0, 1))

Arguments

hc

a hclust object (hierarchical clustering, stats package). First convert df to distances (dist(df)) then hclust(df)

tree.dir

a character object with the direction the tree points to, from root to leaves. options are "down" (default), "up","left", "right".

dir.lims

a 2-member vector with the space in the direction of plotting that the dendrogram will occupy. default = c(0,1)

Value

a data.frame with segment values for ggplot2's geom_seg. columns: "x","xend","y","yend".