Description Usage Arguments Details Value See Also Examples
Extracts data to plot line segments and labels from a tree() object. This data can then be manipulated or plotted, e.g. using ggplot().
1 2 | ## S3 method for class 'tree'
cluster_data(model, ...)
|
model |
object of class "tree", e.g. the output of tree() |
... |
ignored |
Returns a list of three data frames:
$segmentsa data frame containing the line segment data
$labelsa data frame containing the label text data
$leaf_labelsa data frame containing the leaf label text data
a list
1 2 3 4 5 6 7 8 9 10 11 12 13 | require(tree)
require(ggplot2)
data(cpus, package="MASS")
cpus.ltr <- tree(log10(perf) ~ syct+mmin+mmax+cach+chmin+chmax, cpus)
tree_data <- cluster_data(cpus.ltr)
ggplot(tree_data$segments) +
geom_segment(aes(x=x, y=y, xend=xend, yend=yend, size=n),
colour="blue", alpha=0.5) +
scale_size("n", to=c(0, 3)) +
geom_text(data=tree_data$labels,
aes(x=x, y=y, label=label), vjust=-0.5, size=4) +
geom_text(data=tree_data$leaf_labels,
aes(x=x, y=y, label=label), vjust=0.5, size=3)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.