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("maptree-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('maptree') Loading required package: mva Warning: package 'mva' has been merged into 'stats' Loading required package: cluster Loading required package: rpart Loading required package: combinat > > assign(".oldSearch", search(), env = .CheckExEnv) > assign(".oldNS", loadedNamespaces(), env = .CheckExEnv) > cleanEx(); ..nameEx <- "draw.clust" > > ### * draw.clust > > flush(stderr()); flush(stdout()) > > ### Name: draw.clust > ### Title: Graph a Hierarchical Cluster Tree > ### Aliases: draw.clust > ### Keywords: hplot cluster > > ### ** Examples > > library (cluster) > data (oregon.bird.dist) > > draw.clust (prune.clust (agnes (oregon.bird.dist), k=6)) Warning in if (class(cluster) == "hclust") clust <- cluster else if (inherits(cluster, : the condition has length > 1 and only the first element will be used > > > > cleanEx(); ..nameEx <- "draw.tree" > > ### * draw.tree > > flush(stderr()); flush(stdout()) > > ### Name: draw.tree > ### Title: Graph a Classification or Regression Tree > ### Aliases: draw.tree > ### Keywords: hplot tree > > ### ** Examples > > library (rpart) > data (oregon.env.vars) > > draw.tree (prune.Rpart (rpart (oregon.env.vars), best=7), + nodeinfo=TRUE, units="species", cases="cells", digits=0) > > > > cleanEx(); ..nameEx <- "group.clust" > > ### * group.clust > > flush(stderr()); flush(stdout()) > > ### Name: group.clust > ### Title: Observation Groups for a Hierarchical Cluster Tree > ### Aliases: group.clust > ### Keywords: manip cluster > > ### ** Examples > > library (mva) Warning: package 'mva' has been merged into 'stats' > data (oregon.bird.dist, oregon.grid) > > group <- group.clust (hclust (dist (oregon.bird.dist)), k=6) > names(group) <- row.names(oregon.bird.dist) > map.groups (oregon.grid, group) > > > > cleanEx(); ..nameEx <- "group.tree" > > ### * group.tree > > flush(stderr()); flush(stdout()) > > ### Name: group.tree > ### Title: Observation Groups for Classification or Regression Tree > ### Aliases: group.tree > ### Keywords: manip tree > > ### ** Examples > > library (rpart) > data (oregon.env.vars, oregon.grid) > > group <- group.tree (prune.Rpart (rpart (oregon.env.vars), best=7)) > names(group) <- row.names(oregon.env.vars) > map.groups (oregon.grid, group=group) > > > > cleanEx(); ..nameEx <- "kgs" > > ### * kgs > > flush(stderr()); flush(stdout()) > > ### Name: kgs > ### Title: KGS Measure for Pruning Hierarchical Clusters > ### Aliases: kgs > ### Keywords: manip cluster > > ### ** Examples > > library (cluster) > library (combinat) > data (votes.repub) > > a <- agnes (votes.repub, method="ward") > b <- kgs (a, a$diss, maxclust=20) Warning in if (class(cluster) == "hclust") clust <- cluster else if (inherits(cluster, : the condition has length > 1 and only the first element will be used > plot (names (b), b, xlab="# clusters", ylab="penalty") > > > > cleanEx(); ..nameEx <- "map.groups" > > ### * map.groups > > flush(stderr()); flush(stdout()) > > ### Name: map.groups > ### Title: Map Groups of Observations > ### Aliases: map.groups > ### Keywords: hplot cluster tree > > ### ** Examples > > data (oregon.bird.names, oregon.env.vars, oregon.bird.dist) > data (oregon.border, oregon.grid) > > # range map for American Avocet > spp <- match ("American avocet", oregon.bird.names[["common.name"]]) > group <- oregon.bird.dist[,spp] + 1 > names(group) <- row.names(oregon.bird.dist) > map.groups (oregon.grid, group=group, col="gray") > lines (oregon.border) > > # distribution of January temperatures > cuts <- quantile (oregon.env.vars[["jan.temp"]], probs=seq(0,1,1/5)) > group <- cut (oregon.env.vars[["jan.temp"]], cuts, labels=FALSE, + include.lowest=TRUE) > names(group) <- row.names(oregon.env.vars) > map.groups (oregon.grid, group=group, col="gray") > lines (oregon.border) > > # January temperatures using point symbols rather than polygons > map.groups (oregon.env.vars, group, pch=19, col="gray") > lines (oregon.border) > > > > cleanEx(); ..nameEx <- "map.key" > > ### * map.key > > flush(stderr()); flush(stdout()) > > ### Name: map.key > ### Title: Draw Key to accompany Map of Groups > ### Aliases: map.key > ### Keywords: hplot aplot > > ### ** Examples > > data (oregon.env.vars) > > # key for examples in help(map.groups) > # range map for American Avocet > map.key (0.2, 0.2, labels=c("absent","present"), pch=106, + col="gray", head="key", new=TRUE) > # distribution of January temperatures > cuts <- quantile (oregon.env.vars[["jan.temp"]], probs=seq(0,1,1/5)) > map.key (0.2, 0.2, labels=as.character(round(cuts,0)), + col="gray", sep=0, head="key", new=TRUE) > > # key for example in this-is-escaped-codenormal-bracket62bracket-normal > map.key (0.2, 0.2, labels=as.character(seq(6)), + pch=19, head="node", new=TRUE) > > > > cleanEx(); ..nameEx <- "ngon" > > ### * ngon > > flush(stderr()); flush(stdout()) > > ### Name: ngon > ### Title: Outline or Fill a Regular Polygon > ### Aliases: ngon > ### Keywords: aplot > > ### ** Examples > > plot (c(0,1), c(0,1), type="n") > ngon (c(.5, .5, 10, "blue"), angle=30, n=3) > apply (cbind (runif(8), runif(8), 6, 2), 1, ngon) NULL > > > > cleanEx(); ..nameEx <- "prune.Rpart" > > ### * prune.Rpart > > flush(stderr()); flush(stdout()) > > ### Name: prune.Rpart > ### Title: Prunes an Rpart Classification or Regression Tree > ### Aliases: prune.Rpart > ### Keywords: manip cluster > > ### ** Examples > > library (rpart) > data (oregon.env.vars, oregon.border, oregon.grid) > > draw.tree (prune.Rpart (rpart (oregon.env.vars), best=7), + nodeinfo=TRUE, units="species", cases="cells", digits=0) > > group <- group.tree (prune.Rpart (rpart (oregon.env.vars), best=7)) > names(group) <- row.names(oregon.env.vars) > map.groups (oregon.grid, group) > lines (oregon.border) > map.key (0.05, 0.65, labels=as.character(seq(6)), + size=1, new=FALSE, sep=0.5, pch=19, head="node") > > > > cleanEx(); ..nameEx <- "prune.clust" > > ### * prune.clust > > flush(stderr()); flush(stdout()) > > ### Name: prune.clust > ### Title: Prunes a Hierarchical Cluster Tree > ### Aliases: prune.clust > ### Keywords: manip cluster > > ### ** Examples > > library (cluster) > data (oregon.bird.dist) > > draw.clust (prune.clust (agnes (oregon.bird.dist), k=6)) Warning in if (class(cluster) == "hclust") clust <- cluster else if (inherits(cluster, : the condition has length > 1 and only the first element will be used > > > > ### *