hello i have a problem since days with the heatmap function and my own cluster function... i try to put it like this but it is not working : heatmap(data, hclustfun=function(x)myclust(x)) where myclust is a simple fonction myclust= function(data){ #D=dist(data) hc=hclust(D) #mclust= as.mclust(hc$merge) #m=reorder.mclust(data) mc=hc mc$order=leaf return(mc=mc) } and it returns Error in heatmap(data, hclustfun = function(x) myclust(x)) : column dendrogram ordering gave index of wrong length Actually it is working with other cluster fonction like diana() or pam() but not with my own function... Any help ???