As Tal said. Next to that, I read that column1 (and column2?) are supposed to be seen as factors, not as numerical variables. Did you take that into account somehow?
It's easy to reproduce the error code : > n <- NULL > if(n<2)print("This is OK") Error in if (n < 2) print("This is OK") : argument is of length zero In the hclust code, you find following line : n <- as.integer(attr(d, "Size")) where d is the distance object entered in the hclust function. Looking at the error you get, this means that the size attribute of your distance is NULL. Which tells me that distA is not a dist-object. > A <- matrix(1:4,ncol=2) > A [,1] [,2] [1,] 1 3 [2,] 2 4 > hclust(A,method="single") Error in if (n < 2) stop("must have n >= 2 objects to cluster") : argument is of length zero Did you actually put in a distance object? see also ?dist or ?as.dist. Cheers Joris On Fri, May 28, 2010 at 1: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. > -- Joris Meys Statistical Consultant Ghent University Faculty of Bioscience Engineering Department of Applied mathematics, biometrics and process control Coupure Links 653 B-9000 Gent tel : +32 9 264 59 87 joris.m...@ugent.be ------------------------------- Disclaimer : http://helpdesk.ugent.be/e-maildisclaimer.php [[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.