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("amap-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('amap') > > assign(".oldSearch", search(), env = .CheckExEnv) > assign(".oldNS", loadedNamespaces(), env = .CheckExEnv) > cleanEx(); ..nameEx <- "acp" > > ### * acp > > flush(stderr()); flush(stdout()) > > ### Name: acp > ### Title: Principal component analysis > ### Aliases: acp pca print.acp > ### Keywords: multivariate > > ### ** Examples > > data(lubisch) > lubisch <- lubisch[,-c(1,8)] > p <- acp(lubisch) > plot(p) > > > > cleanEx(); ..nameEx <- "acpgen" > > ### * acpgen > > flush(stderr()); flush(stdout()) > > ### Name: acpgen > ### Title: Generalised principal component analysis > ### Aliases: acpgen K W WsansC > ### Keywords: multivariate > > ### ** Examples > > data(lubisch) > lubisch <- lubisch[,-c(1,8)] > p <- acpgen(lubisch,h1=1,h2=1/sqrt(2)) > plot(p,main='ACP robuste des individus') > > # See difference with acp > > p <- acp(lubisch) > plot(p) > > # Other Data > .Random.seed <- c(1, 416884367 ,1051235439) > n <- 100 # Number of observations > m <- 0 # Mean of 1 group > temp <- cbind(rnorm(n,m,1),rnorm(n,0,10)) > m <- 10 > mat <- rbind(temp,cbind(rnorm(n,m,1),rnorm(n,0,10))) > mat <- scale(mat,TRUE,TRUE) > rm (m,n,temp) > > > > > cleanEx(); ..nameEx <- "dist" > > ### * dist > > flush(stderr()); flush(stdout()) > > ### Name: Dist > ### Title: Distance Matrix Computation > ### Aliases: Dist > ### Keywords: multivariate cluster > > ### ** Examples > > x <- matrix(rnorm(100), nrow=5) > Dist(x) 1 2 3 4 2 5.701817 3 6.013119 5.032069 4 7.276905 5.325473 5.811861 5 6.619295 5.306750 4.945987 6.612081 > Dist(x, diag = TRUE) 1 2 3 4 5 1 0.000000 2 5.701817 0.000000 3 6.013119 5.032069 0.000000 4 7.276905 5.325473 5.811861 0.000000 5 6.619295 5.306750 4.945987 6.612081 0.000000 > Dist(x, upper = TRUE) 1 2 3 4 5 1 5.701817 6.013119 7.276905 6.619295 2 5.701817 5.032069 5.325473 5.306750 3 6.013119 5.032069 5.811861 4.945987 4 7.276905 5.325473 5.811861 6.612081 5 6.619295 5.306750 4.945987 6.612081 > > > > > cleanEx(); ..nameEx <- "distpar" > > ### * distpar > > flush(stderr()); flush(stdout()) > > ### Name: distpar > ### Title: Parallelized Distance Matrix Computation > ### Aliases: distpar > ### Keywords: multivariate cluster > > ### ** Examples > > x <- matrix(rnorm(100), nrow=5) > > ## compute dist with 8 threads > distpar(x,nbproc=8) 1 2 3 4 2 5.701817 3 6.013119 5.032069 4 7.276905 5.325473 5.811861 5 6.619295 5.306750 4.945987 6.612081 > > ## compute pearson dist with 8 threads > distpar(x,nbproc=8,method="pearson") 1 2 3 4 2 1.1629925 3 1.1584844 1.0825533 4 1.3551134 0.9010061 0.9812551 5 1.1997694 0.9815441 0.7656573 1.1024095 > > > > > cleanEx(); ..nameEx <- "hcluster" > > ### * hcluster > > flush(stderr()); flush(stdout()) > > ### Name: hcluster > ### Title: Hierarchical Clustering > ### Aliases: hcluster > ### Keywords: multivariate cluster > > ### ** Examples > > > data(USArrests) > hc <- hcluster(USArrests,link = "ave") > plot(hc) > plot(hc, hang = -1) > > ## Do the same with centroid clustering and squared Euclidean distance, > ## cut the tree into ten clusters and reconstruct the upper part of the > ## tree from the cluster centers. > hc <- hclust(dist(USArrests)^2, "cen") > memb <- cutree(hc, k = 10) > cent <- NULL > for(k in 1:10){ + cent <- rbind(cent, colMeans(USArrests[memb == k, , drop = FALSE])) + } > hc1 <- hclust(dist(cent)^2, method = "cen", members = table(memb)) > opar <- par(mfrow = c(1, 2)) > plot(hc, labels = FALSE, hang = -1, main = "Original Tree") > plot(hc1, labels = FALSE, hang = -1, main = "Re-start from 10 clusters") > par(opar) > > > > graphics::par(get("par.postscript", env = .CheckExEnv)) > cleanEx(); ..nameEx <- "hclusterpar" > > ### * hclusterpar > > flush(stderr()); flush(stdout()) > > ### Name: hclusterpar > ### Title: Parallelized Hierarchical Clustering > ### Aliases: hclusterpar > ### Keywords: multivariate cluster > > ### ** Examples > > > data(USArrests) > hc <- hclusterpar(USArrests,link = "ave",nbproc=8) > plot(hc) > plot(hc, hang = -1) > > ## To check... > hc <- hcluster(USArrests,link = "ave") > plot(hc) > ## The same ? > > > > > cleanEx(); ..nameEx <- "plot.acp" > > ### * plot.acp > > flush(stderr()); flush(stdout()) > > ### Name: plot.acp > ### Title: Graphics for Principal component Analysis > ### Aliases: plot.acp biplot.acp plot2.acp > ### Keywords: multivariate > > ### ** Examples > > data(lubisch) > lubisch <- lubisch[,-c(1,8)] > p <- acp(lubisch) > plot(p) > > > > ### *