Hi, I had 10000 genes, and I clustered them using K-means clustering in R. kc<-kmeans(data.sub,7) kc n cluster sum of squares by cluster: [1] 60631.76 135886.19 159049.71 101783.27 90040.72 183335.60 158867.81 Available components: [1] "cluster" "centers" "withinss" "size" I am very new to R. How do i measure the distance between those cluster? I tried I am trying to do a complete linkage>z<-hclust(kc,method="complete")Error in if (n < 2) stop("must have n >= 2 objects to cluster") : argument is of length zero thanks. -- View this message in context: http://www.nabble.com/Newbie%3A-Measuring-distance-between-clusters.-tp15650066p15650066.html Sent from the R help mailing list archive at Nabble.com.
Bill.Venables at csiro.au
2008-Feb-24 03:49 UTC
[R] Newbie: Measuring distance between clusters.
One way to do it is to find the distances between ther "centers" (centres in English) of the clusters. dist(kc$centers) It rather depends on how you define distances between clusters, though. There are many possibilities. -----Original Message----- From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf Of Keizer_71 Sent: Saturday, 23 February 2008 7:40 PM To: r-help at r-project.org Subject: [R] Newbie: Measuring distance between clusters. Hi, I had 10000 genes, and I clustered them using K-means clustering in R. kc<-kmeans(data.sub,7) kc n cluster sum of squares by cluster: [1] 60631.76 135886.19 159049.71 101783.27 90040.72 183335.60 158867.81 Available components: [1] "cluster" "centers" "withinss" "size" I am very new to R. How do i measure the distance between those cluster? I tried I am trying to do a complete linkage>z<-hclust(kc,method="complete")Error in if (n < 2) stop("must have n >= 2 objects to cluster") : argument is of length zero thanks. -- View this message in context: http://www.nabble.com/Newbie%3A-Measuring-distance-between-clusters.-tp1 5650066p15650066.html Sent from the R help mailing list archive at Nabble.com. ______________________________________________ R-help at 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.
It works! I was banging my head for a week. thank you so much. Bill.Venables wrote:> > One way to do it is to find the distances between ther "centers" (> centres in English) of the clusters. > > dist(kc$centers) > > It rather depends on how you define distances between clusters, though. > There are many possibilities. > > -----Original Message----- > From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] > On Behalf Of Keizer_71 > Sent: Saturday, 23 February 2008 7:40 PM > To: r-help at r-project.org > Subject: [R] Newbie: Measuring distance between clusters. > > > Hi, > > I had 10000 genes, and I clustered them using K-means clustering in R. > > kc<-kmeans(data.sub,7) > > kc > n cluster sum of squares by cluster: > [1] 60631.76 135886.19 159049.71 101783.27 90040.72 183335.60 > 158867.81 > > Available components: > [1] "cluster" "centers" "withinss" "size" > > I am very new to R. How do i measure the distance between those cluster? > > I tried > > I am trying to do a complete linkage > >>z<-hclust(kc,method="complete") > > Error in if (n < 2) stop("must have n >= 2 objects to cluster") : > argument is of length zero > > thanks. > > > -- > View this message in context: > http://www.nabble.com/Newbie%3A-Measuring-distance-between-clusters.-tp1 > 5650066p15650066.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-help at 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. > > ______________________________________________ > R-help at 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. > >-- View this message in context: http://www.nabble.com/Newbie%3A-Measuring-distance-between-clusters.-tp15650066p15665075.html Sent from the R help mailing list archive at Nabble.com.