Execute <- function(mat) { setClass("TransformationResult", representation( newParamData="matrix", numberOfNewParams="integer", newParamNames="character" ), prototype( newParamData=c(), numberOfNewParams=as.integer(0), newParamNames="" ) ) result <- new("TransformationResult") result@numberOfNewParams <- as.integer(A) result@newParamData <- B result@newParamNames <- C return(result) } ##Script Ends ------------------------------------------------------ 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 result of any user-defined transformation. B must be an object of class matrix with events in columns and parameters in rows. The number of events (i.e. the number of columns) must match the number of events in the mat matrix and the number of parameters (i.e. the number of rows) must match the value defined in B. C is a vector of class character containing the names of the new parameters. Multiple names can be specified using the c() function (e.g. c("name1","name2","name3") ). Please also note that the name of the parameters included in the mat matrix are accessible in R by using the rownames() or the colnames() functions (when parameter are in rows and in columns respectively). Thus parameter names can be derived and used as part of generating new parameter names.