Clustering in R

From Rizzo_Lab
Revision as of 14:37, 17 June 2008 by Tbalius (talk | contribs)
(diff) ←Older revision | view current revision (diff) | Newer revision→ (diff)
Jump to: navigation, search

file.in

#
#read in file
x = read.csv("matrix.csv")
#
# creat a dendogram
library(cluster)
c = agnes(x)
c2 = as.hclust(c)
#
# cut into clusters
memb = cutree(c2, k = 3)
#
# creat a comma seperated file
write.table(memb, file = "temp.csv", append = FALSE, quote = FALSE, sep = ", ")
#
# creat an image
postscript("file.ps")
plot(c2)
q()

R --no-save < file.in