R: Recursive function to calculate the length of branches

cal_length {dendsort} | R Documentation

## Recursive function to calculate the length of branches

### Description

`cal_length` is a code modified from plotNode() to calculate the length of lines to draw the branch of a dendrogram. This function was developed to evaluate the use of ink for visualization.

### Usage

    cal_length(x1, x2, subtree, center, nodePar, edgePar, horiz = FALSE, sum)

### Arguments

`x1` | A x coordinate`x1`
`x2` | Another x coordinate`x2`
`subtree` | A dendrogram object.`subtree`
`center` | A logical whether the dendrogram is centered.`center`
`nodePar` | A node parameter.`nodePar`
`edgePar` | An edge parameter.`edgePar`
`horiz` | A logical about layout.`horiz`
`sum` | A sum of length.`sum`

### Value

output The length.

### Examples

    #generate sample data
    set.seed(1234); par(mar=c(0,0,0,0))
    x <- rnorm(10, mean=rep(1:5, each=2), sd=0.4)
    y <- rnorm(10, mean=rep(c(1,2), each=5), sd=0.4)
    dataFrame <- data.frame(x=x, y=y, row.names=c(1:10))
    #calculate Euclidian distance
    distxy <- dist(dataFrame)
    #hierachical clustering "complete" linkage by default
    hc <- hclust(distxy)

    total_length <- cal_total_length(as.dendrogram(hc))

[Package dendsort version 0.3.3 Index]