4

I am new to R. I am trying to do hclust and export the cluster membership. I have used the following. Is this correct or is there a better way?

FCtable1<-as.matrix(read.delim("table1.txt", row.names=1, header=TRUE, sep="\t"))
Disttab1<-dist(FCtable1, method="euclidean")
Hclustout1<-hclust(Disttab1, method="average")
clustnumber<- cutree(Hclustout1, h=1000)
tab1clustn <-data.frame(FCtable1, clustnumber)
write.table(tab1clustn,  file=" tab1clustn.xls", row.names=T, sep="\t")

Thanks R

user1569742
  • 51
  • 1
  • 5
  • 2
    Assuming that tab1clustn <-data.frame(table1, clustnumber) should be tab1clustn <-data.frame(FCtable1, clustnumber), it should work. You can also specify the number of clusters instead of the height in cutree(). – dcarlson Oct 10 '12 at 19:28
  • Great. Thanks a lot. Yes, table1 is a typo. – user1569742 Oct 10 '12 at 19:36

0 Answers0