Getting node error while trying to print dendrogram

I am trying to get the height of the internal dendrogram nodes in BFS order.

The utils::str function prints the dendrogram in BFS order. So I thought I would use this (redirect the output to a file and parse to get the information I need).

My 'dendrogram' has 2 branches and 5902 members download the link of the RDS file: dendro.RDS .

When I try:

 utils::str(dendro) 

I get this error:

 Error in getOption("OutDec") : node stack overflow Error during wrapup: node stack overflow 

I tried using a simple recursion function:

 nodeHeights <- function(dendro){ if(is.leaf(dendro)) 0 else{ cat(attr(dendro,"height"),"\n") max(nodeHeights(dendro[[1]]),nodeHeights(dendro[[2]]))+1 } } 

But: nodeHeights (dendro)

Throws this error:

 Error: evaluation nested too deeply: infinite recursion / options(expressions=)? Error during wrapup: evaluation nested too deeply: infinite recursion / options(expressions=)? 

Any idea? Or any suggestion on how to get node a dendrogram in BFS order?

+5
source share
2 answers
 > options(expressions=10000) > nodeHeights(dendro) [1] 1084 

From ?options :

expresses a limit on the number of nested expressions to be evaluated

+2
source

Adding ulimit -s <high_value> to my .bashrc did the trick.

+1
source

All Articles