R : Copyright 2005, The R Foundation for Statistical Computing Version 2.1.1 (2005-06-20), ISBN 3-900051-07-0 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for a HTML browser interface to help. Type 'q()' to quit R. > ### *
> ### > attach(NULL, name = "CheckExEnv") > assign(".CheckExEnv", as.environment(2), pos = length(search())) # base > ## add some hooks to label plot pages for base and grid graphics > setHook("plot.new", ".newplot.hook") > setHook("persp", ".newplot.hook") > setHook("grid.newpage", ".gridplot.hook") > > assign("cleanEx", + function(env = .GlobalEnv) { + rm(list = ls(envir = env, all.names = TRUE), envir = env) + RNGkind("default", "default") + set.seed(1) + options(warn = 1) + delayedAssign("T", stop("T used instead of TRUE"), + assign.env = .CheckExEnv) + delayedAssign("F", stop("F used instead of FALSE"), + assign.env = .CheckExEnv) + sch <- search() + newitems <- sch[! sch %in% .oldSearch] + for(item in rev(newitems)) + eval(substitute(detach(item), list(item=item))) + missitems <- .oldSearch[! .oldSearch %in% sch] + if(length(missitems)) + warning("items ", paste(missitems, collapse=", "), + " have been removed from the search path") + }, + env = .CheckExEnv) > assign("..nameEx", "__{must remake R-ex/*.R}__", env = .CheckExEnv) # for now > assign("ptime", proc.time(), env = .CheckExEnv) > grDevices::postscript("cclust-Examples.ps") > assign("par.postscript", graphics::par(no.readonly = TRUE), env = .CheckExEnv) > options(contrasts = c(unordered = "contr.treatment", ordered = "contr.poly")) > options(warn = 1) > library('cclust') > > assign(".oldSearch", search(), env = .CheckExEnv) > assign(".oldNS", loadedNamespaces(), env = .CheckExEnv) > cleanEx(); ..nameEx <- "Rindexes" > > ### * Rindexes > > flush(stderr()); flush(stdout()) > > ### Name: clustIndex > ### Title: Cluster Indexes > ### Aliases: clustIndex > ### Keywords: cluster > > ### ** Examples > > # a 2-dimensional example > x<-rbind(matrix(rnorm(100,sd=0.3),ncol=2), + matrix(rnorm(100,mean=1,sd=0.3),ncol=2)) > cl<-cclust(x,2,20,verbose=TRUE,method="kmeans") Iteration: 1 Changes: 51 Iteration: 2 Changes: 2 Iteration: 3 Changes: 0 > resultindexes <- clustIndex(cl,x, index="all") > resultindexes calinski cindex db hartigan ratkowsky scott 302.6691152 NA 0.2192710 1.1276727 0.6147506 188.8758605 marriot ball trcovw tracew friedman rubin 227.7817782 7.4589482 49.9039448 15.2216923 5.6687377 6.6111565 ssi likelihood xuindex 0.9404286 15.8764532 -6.5077788 > > > > cleanEx(); ..nameEx <- "cclust" > > ### * cclust > > flush(stderr()); flush(stdout()) > > ### Name: cclust > ### Title: Convex Clustering > ### Aliases: cclust kmeans hardcl neuralgas print.cclust > ### Keywords: cluster > > ### ** Examples > > ## a 2-dimensional example > x<-rbind(matrix(rnorm(100,sd=0.3),ncol=2), + matrix(rnorm(100,mean=1,sd=0.3),ncol=2)) > cl<-cclust(x,2,20,verbose=TRUE,method="kmeans") Iteration: 1 Changes: 51 Iteration: 2 Changes: 2 Iteration: 3 Changes: 0 > plot(x, col=cl$cluster) > > ## a 3-dimensional example > x<-rbind(matrix(rnorm(150,sd=0.3),ncol=3), + matrix(rnorm(150,mean=1,sd=0.3),ncol=3), + matrix(rnorm(150,mean=2,sd=0.3),ncol=3)) > cl<-cclust(x,6,20,verbose=TRUE,method="kmeans") Iteration: 1 Changes: 100 Iteration: 2 Changes: 10 Iteration: 3 Changes: 7 Iteration: 4 Changes: 9 Iteration: 5 Changes: 3 Iteration: 6 Changes: 0 > plot(x, col=cl$cluster) > > ## assign classes to some new data > y<-rbind(matrix(rnorm(33,sd=0.3),ncol=3), + matrix(rnorm(33,mean=1,sd=0.3),ncol=3), + matrix(rnorm(3,mean=2,sd=0.3),ncol=3)) > ycl<-predict(cl, y) > plot(y, col=ycl$cluster) > > > > cleanEx(); ..nameEx <- "predict.cclust" > > ### * predict.cclust > > flush(stderr()); flush(stdout()) > > ### Name: predict.cclust > ### Title: Assign clusters to new data > ### Aliases: predict.cclust > ### Keywords: cluster > > ### ** Examples > > # a 2-dimensional example > x<-rbind(matrix(rnorm(100,sd=0.3),ncol=2), + matrix(rnorm(100,mean=1,sd=0.3),ncol=2)) > cl<-cclust(x,2,20,verbose=TRUE,method="kmeans") Iteration: 1 Changes: 51 Iteration: 2 Changes: 2 Iteration: 3 Changes: 0 > plot(x, col=cl$cluster) > > # a 3-dimensional example > x<-rbind(matrix(rnorm(150,sd=0.3),ncol=3), + matrix(rnorm(150,mean=1,sd=0.3),ncol=3), + matrix(rnorm(150,mean=2,sd=0.3),ncol=3)) > cl<-cclust(x,6,20,verbose=TRUE,method="kmeans") Iteration: 1 Changes: 100 Iteration: 2 Changes: 10 Iteration: 3 Changes: 7 Iteration: 4 Changes: 9 Iteration: 5 Changes: 3 Iteration: 6 Changes: 0 > plot(x, col=cl$cluster) > > # assign classes to some new data > y<-rbind(matrix(rnorm(33,sd=0.3),ncol=3), + matrix(rnorm(33,mean=1,sd=0.3),ncol=3), + matrix(rnorm(3,mean=2,sd=0.3),ncol=3)) > ycl<-predict(cl, y) > plot(y, col=ycl$cluster) > > > > ### *