1 AssignClasseToUce<-function(listuce,chd) {
2 out<-matrix(nrow=nrow(listuce),ncol=ncol(chd))
3 for (i in 1:nrow(listuce)) {
4 for (j in 1:ncol(chd)) {
5 out[i,j]<-chd[(listuce[i,2]+1),j]
13 pamtxt <- function(dm, listucein, uceout, method = 'binary', clust_type = 'pam', clnb = 3) {
14 listuce <- read.csv2(listucein)
15 x <- read.csv2(dm, header = FALSE)
18 distmat <- dist(x,method = method)
19 if (clust_type == 'pam')
20 cl <- pam(distmat, clnb, diss=TRUE)
21 else if (clust_type == 'fanny')
22 cl <- fanny(distmat, clnb, diss=TRUE, memb.exp = 1.001)
23 cld <- as.data.frame(cl$clustering)
24 colnames(cld) <- 'classes'
25 out <- as.data.frame(AssignClasseToUce(listuce,cld))
26 write.csv2(out[,1],uceout)
27 result <- list(uce = out, cl = cl)