On Tue, Dec 30, 2008 at 8:44 AM, <mau...@alice.it> wrote: > It is no homework. It is part of a project where a binary matrix, whose 1s > represent the position of the highest DWT coefficients energy, is used as a > template to extract signal features. > The approach I am following requires each row of the binary matrix > (correspondent to a DWT scale level) to be clustered separately subject to > the requirements of generating as many clusters as the numbers of 1s and > having the 1s a the centers of the respective clusters.
Perhaps look into the rle (run-length encoding) function? It may be useful to you directly, or the methods it uses internally may be useful. -s PS The word 'cluster' may be confusing in some contexts. Perhaps it would be better to call them 'runs'. ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.