Learn R Programming

dendextendRcpp (version 0.5.0)

dendextendRcpp_get_branches_heights: Get branches height attr from a dendrogram

Description

Get branches height attributes from a dendrogram. This function is intended to override get_branches_heights. Since it is 40-100 times faster.

Usage

dendextendRcpp_get_branches_heights(tree, sort = TRUE, decreasing = FALSE,
  ...)

Arguments

Value

A numeric vector of the dendrogram's nodes heights (excluding leaves).

See Also

labels, dendrogram, attr

Examples

Run this code
dend = as.dendrogram(hclust(dist(iris[1:150,-5])))
plot(dend)
get_height(dend)


attributes(dend) <- NULL
Rcpp_get_dend_heights(dend) # knows to through a warning :)

dend = as.dendrogram(hclust(dist(iris[1:150,-5])))
Rcpp_get_dend_heights(dend)
get_branches_heights(dend)
Rcpp_get_dend_heights(dend,T,F)
Rcpp_get_dend_heights(dend,T,F)

# require(dendextend)
Rcpp_get_dend_heights(dend)
dendextendRcpp_get_branches_heights(dend,sort=F)


require(microbenchmark)
microbenchmark(
   dendextendRcpp::dendextendRcpp_get_branches_heights(dend),
   old_get_branches_heights(dend,sort=F)
)
# Rcpp is about 40-107 times faster!

Run the code above in your browser using DataLab