data(badDend)
dist2 <- function(x) as.dist(1 - cor(t(x), method = "pearson"))
hclust1 <- function(x) hclust(x, method = "single")
distance <- dist2(badDend)
cluster <- hclust1(distance)
dend <- as.dendrogram(cluster)
if (FALSE) {
## In R 2.3.0 and earlier crashes with a node stack overflow error
plot(dend)
## Error in xy.coords(x, y, recycle = TRUE) : node stack overflow
}
## convert stats:::plotNode from byte-code to interpreted-code
## (no longer available unless assignEdgewise is defined by the user)
## unByteCodeAssign(stats:::plotNode)
## illustrated in https://stackoverflow.com/questions/16559250/error-in-heatmap-2-gplots
# increase recursion limit
options("expressions" = 5e4)
# now the function does not crash
plot(dend)
Run the code above in your browser using DataLab