Clustering in R

From Rizzo_Lab
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