Execute <- function(mat) { setClass("ClusteringResult", representation( clusterAssignments="integer", numberOfClusters="integer", clusterNames="character" ), prototype( clusterAssignments=c(), numberOfClusters=integer(0), clusterNames="" ) ) result <- new("ClusteringResult") result@numberOfClusters <- as.integer(A) result@clusterAssignments <- as.integer(B) result@clusterNames <- C return(result) } ##Script Ends ------------------------------------------------------ Description Where A, B and C values are defined by the user. As stated above: A can be any integer number. Note that the as.integer() function is required since numbers are otherwise stored as object of class numeric; B can be the membership resulting from any user-defined clustering. It must be a vector of integer values of length equal to the number of events of the mat matrix. The number of unique integer values must be equal to A. The numbering of clusters must begin at 0. C is a vector of class character containing the names of the clusters. Multiple names can be specified using the c() function (e.g. c("name1","name2","name3") ). The length has to be equal to A.