Hi Ayesha, hclust is a way to go (much better then trying to invent the wheel here).
Please add what you used to create: distA And create a sample data set to show us what you did, using dput Best, Tal ----------------Contact Details:------------------------------------------------------- Contact me: tal.gal...@gmail.com | 972-52-7275845 Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) | www.r-statistics.com (English) ---------------------------------------------------------------------------------------------- On Fri, May 28, 2010 at 2:41 AM, Ayesha Khan <ayesha.diamond...@gmail.com>wrote: > i have a matrix with the following dimensions > 136 3 > > and it looks something like > > [,1] [,2] [,3] > [1,] 402 675 1.802758 > [2,] 402 696 1.938902 > [3,] 402 699 1.994253 > [4,] 402 945 1.898619 > [5,] 424 470 1.812857 > [6,] 424 905 1.816345 > [7,] 470 905 1.871252 > [8,] 504 780 1.958191 > [9,] 504 848 1.997111............... > > ................................................................................ > so you get the idea. I want to group similar items in one group/cluster > following the "friends of friends" approach. I tried doing > > distclust <- hclust(distA,method="single") > However, I got the following error. > > Error in if (n < 2) stop("must have n >= 2 objects to cluster") : argument > is of length zero > which probably means there's something wrong with my input here. Is there > another way of doing this kind of clustering without getting into all the > looping and ifelse etc. Basically, if 402 is close to 675,696,and699 and > thus fall in cluster A then all items close to 675,696,and 699 should also > fall into the same cluster A following a friends of friedns strategy. > Any help would be highly appreciated. > > -- > Ayesha Khan > > MS Bioengineering > Dept. of Bioengineering > Rice University, TX > > [[alternative HTML version deleted]] > > ______________________________________________ > 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. > [[alternative HTML version deleted]] ______________________________________________ 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.