Description Usage Arguments Value Examples
This is the Rcpp version of the heights_per_k.dendrogram from the dendextend R package. It is intended to override that function in order to get a speed gain of ranging from 10 times faster (for a tree with 3 leaves), to 130 times (!) faster (for a tree with 150 leaves).
1 |
tree |
a dendrogram. |
... |
not used. |
a vector of heights, with its names being the k clusters that will result for cutting the dendrogram at each height.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | ## Not run:
dend = as.dendrogram(hclust(dist(iris[1:150,-5])))
# plutral heightS
dendextendRcpp_heights_per_k.dendrogram(dend,1)
dendextendRcpp_heights_per_k.dendrogram(dend,.5)
dendextendRcpp_heights_per_k.dendrogram(dend,0.05)
dendextendRcpp_heights_per_k.dendrogram(dend,0)
dendextendRcpp_heights_per_k.dendrogram(dend,-1)
dendextendRcpp_heights_per_k.dendrogram(dend,c(1,.5,.2,0,-1))
\dontrun{
require(microbenchmark)
dend = as.dendrogram(hclust(dist(iris[1:150,-5])))
dend = as.dendrogram(hclust(dist(iris[1:30,-5])))
dend = as.dendrogram(hclust(dist(iris[1:3,-5])))
microbenchmark(
# dendextendRcpp::heights_per_k.dendrogram(dend),
dendextendRcpp::dendextendRcpp_heights_per_k.dendrogram(dend),
dendextend::old_heights_per_k.dendrogram(dend)
)
# improvment is 10 times faster (in Rcpp) for a tree of size 3
# 76 times faster for a tree of size 30
# And:
# 134 times faster for a tree of size 150!!
}
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.