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("xgobi-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('xgobi') > > assign(".oldSearch", search(), env = .CheckExEnv) > assign(".oldNS", loadedNamespaces(), env = .CheckExEnv) > cleanEx(); ..nameEx <- "PaulKAI" > > ### * PaulKAI > > flush(stderr()); flush(stdout()) > > ### Name: PaulKAI > ### Title: Occurences of ``kai'' in 10 Epistels of Apostel Paul > ### Aliases: PaulKAI > ### Keywords: datasets > > ### ** Examples > > data(PaulKAI) > rownames(PaulKAI) # the ten epistles researched: [1] "Rom" "Co1" "Co2" "Gal" "Phi" "Col" "Th1" "Ti1" "Ti2" "Heb" > ##> [1] "Rom" "Co1" "Co2" "Gal" "Phi" "Col" "Th1" "Ti1" "Ti2" "Heb" > PaulKAI # the 10 x 4 count table 0 1 2 3+ Rom 386 141 34 17 Co1 424 152 35 16 Co2 192 86 28 13 Gal 128 48 5 6 Phi 42 29 19 12 Col 23 32 17 9 Th1 34 23 8 16 Ti1 49 38 9 10 Ti2 45 28 11 4 Heb 155 94 37 24 > mosaicplot(PaulKAI) > quadplot(PaulKAI) xgobi -title 'mat3' -std mmx /tmp/RtmpiVHdhY/xgobi-mat310d63af1 & sh: line 1: xgobi: command not found > > > > cleanEx(); ..nameEx <- "morsecodes" > > ### * morsecodes > > flush(stderr()); flush(stdout()) > > ### Name: morsecodes > ### Title: Rothkopf Morse Code Data > ### Aliases: morsecodes morsecodes.col morsecodes.colors morsecodes.dist > ### morsecodes.glyphs morsecodes.linecolors morsecodes.lines > ### morsecodes.pos morsecodes.raw morsecodes.row > ### Keywords: datasets > > ### ** Examples > > data(morsecodes) > ls.str(pat="^morsecode") morsecodes.col : chr [1:12] "LEN" "DASH" "POS 1" "POS 2" "POS 3" "POS 4" "POS 5" "SEQ" ... morsecodes.colors : chr [1:36] "SkyBlue" "Green" "Green" "Yellow" "HotPink" "Green" "Yellow" ... morsecodes.dist : int [1:36, 1:36] 0 167 169 159 180 164 163 163 75 165 ... morsecodes.glyphs : num [1:36] 27 27 27 27 27 27 27 27 27 27 ... morsecodes.linecolors : chr [1:33] "SkyBlue" "SkyBlue" "Green" "Green" "Green" "Green" "Yellow" ... morsecodes.lines : num [1:33, 1:2] 1 1 2 2 3 3 4 4 5 6 ... morsecodes.pos : num [1:36, 1:12] 0.25 0.75 0.75 0.5 0 0.75 0.5 0.75 0.25 0.75 ... morsecodes.raw : int [1:36, 1:36] 92 5 4 8 6 4 9 3 64 7 ... morsecodes.row : chr [1:36, 1:2] "A" "B" "C" "D" "E" "F" "G" "H" "I" "J" "K" "L" "M" "N" ... > morsecodes.row # remember what you learned in... [,1] [,2] [1,] "A" ".-" [2,] "B" "-..." [3,] "C" "-.-." [4,] "D" "-.." [5,] "E" "." [6,] "F" "..-." [7,] "G" "--." [8,] "H" "...." [9,] "I" ".." [10,] "J" ".---" [11,] "K" "-.-" [12,] "L" ".-.." [13,] "M" "--" [14,] "N" "-." [15,] "O" "---" [16,] "P" ".--." [17,] "Q" "--.-" [18,] "R" ".-." [19,] "S" "..." [20,] "T" "-" [21,] "U" "..-" [22,] "V" "...-" [23,] "W" ".--" [24,] "X" "-..-" [25,] "Y" "-.--" [26,] "Z" "--.." [27,] "1" ".----" [28,] "2" "..---" [29,] "3" "...--" [30,] "4" "....-" [31,] "5" "....." [32,] "6" "-...." [33,] "7" "--..." [34,] "8" "---.." [35,] "9" "----." [36,] "0" "-----" > ## real row names > (mc.row <- paste(morsecodes.row[,1], morsecodes.row[,2]))[1:8] [1] "A .-" "B -..." "C -.-." "D -.." "E ." "F ..-." "G --." "H ...." > > image(1:36, 1:36, morsecodes.raw, main="`morsecodes' raw confusion rates") > text(1:36,1:36, morsecodes.row[,1]) > > ##--> help(xgvis) for running multidimensional scaling (MDS) and XGobi on these > > > > cleanEx(); ..nameEx <- "quadplot" > > ### * quadplot > > flush(stderr()); flush(stdout()) > > ### Name: quadplot > ### Title: Tetrahedral Display for Four-Category Proportions using XGobi > ### Aliases: quadplot > ### Keywords: dynamic hplot > > ### ** Examples > > data(PaulKAI) > quadplot(PaulKAI, normalize = TRUE) xgobi -title 'mat3' -std mmx /tmp/RtmpiVHdhY/xgobi-mat360b7acd9 & sh: line 1: xgobi: command not found > > > > cleanEx(); ..nameEx <- "reggeom" > > ### * reggeom > > flush(stderr()); flush(stdout()) > > ### Name: reggeom > ### Title: Geometry of Regression with Two Regressors > ### Aliases: reggeom > ### Keywords: dynamic > > ### ** Examples > > reggeom() xgobi -title 'Regression Geometry' -std msd /tmp/RtmpiVHdhY/xgobi-RgrsG3ab50c2a & sh: line 1: xgobi: command not found > > ## The arguments given in this example are modifications of the default, > ## some lines dropped, some added, some line colors changed, > ## in order to emphasize the geometry of backfitting. > reggeom( + lines= cbind(c(1,6,8,1,11,7,1,1,6,6,15,17,8,5,9, 5,6,14,15,16,14,15,5), + c(6,8,2,11,7,3,4,5,4,15,17,5,5,9,7,11,14,15,16,17,4,4,4)), + linecolors=c("red", rep("yellow",5), "orchid", "green", + "slateblue", rep("skyblue",3), rep("white",3), "skyblue", + rep("red",4), rep("slateblue", 2), "green"), + title="Regression Geometry - Backfitting") xgobi -title 'Regression Geometry - Backfitting' -std msd /tmp/RtmpiVHdhY/xgobi-RgrGB4431b782 & sh: line 1: xgobi: command not found > > > > cleanEx(); ..nameEx <- "xgobi" > > ### * xgobi > > flush(stderr()); flush(stdout()) > > ### Name: xgobi > ### Title: XGobi: Dynamic Graphics for Data Analysis > ### Aliases: xgobi xgobi.colors.default > ### Keywords: dynamic multivariate > > ### ** Examples > > data(laser) > xgobi(laser) xgobi -title 'laser' -std mmx /tmp/RtmpiVHdhY/xgobi-laser1c06dac8 & sh: line 1: xgobi: command not found > > Xdir <- file.path(dirname(tempfile()), "xgobi") > ## Don't show: > if(file.exists(Xdir)) unlink(Xdir, recursive = TRUE) > ## End Don't show > dir.create(Xdir) > xgobi(laser, colors = xgobi.colors.default[c(1,3,5,7,9,10)[as.factor(laser$ Ir)]], + glyphs = c(23,8)[1+(laser$lambda > 1576)], + keep = TRUE, fprefix="xgobi/L-") xgobi -title 'laser' -std mmx /tmp/RtmpiVHdhY/xgobi/L-laser56e509fe & sh: line 1: xgobi: command not found > file.info(list.files(Xdir, full=TRUE))[, c(1,3,4)] # >> Files "L-laser..." size mode mtime /tmp/RtmpiVHdhY/xgobi/L-laser56e509fe 1196 644 2005-07-13 20:40:29 /tmp/RtmpiVHdhY/xgobi/L-laser56e509fe.col 19 644 2005-07-13 20:40:29 /tmp/RtmpiVHdhY/xgobi/L-laser56e509fe.colors 698 644 2005-07-13 20:40:29 /tmp/RtmpiVHdhY/xgobi/L-laser56e509fe.glyphs 143 644 2005-07-13 20:40:29 /tmp/RtmpiVHdhY/xgobi/L-laser56e509fe.row 183 644 2005-07-13 20:40:29 > ## remove manually when finally unused: > unlink(Xdir, recursive = TRUE) > > ##>>> see also the morsecodes example in help(xgvis) <<< > ## ------------------ ----------- > > > > cleanEx(); ..nameEx <- "xgvis" > > ### * xgvis > > flush(stderr()); flush(stdout()) > > ### Name: xgvis > ### Title: XGvis: Interactive Multidimensional Scaling Using XGobi for > ### Display > ### Aliases: xgvis > ### Keywords: dynamic multivariate > > ### ** Examples > > data(morsecodes) ## from the XGobi/XGvis data, see ?morsecodes > mc.row <- paste(morsecodes.row[,1],morsecodes.row[,2]) > > xgvis(dmat = morsecodes.dist, + pos = morsecodes.pos, + rowlab = mc.row, + colors = morsecodes.colors, + glyphs = morsecodes.glyphs, + lines = morsecodes.lines, + linecolors = morsecodes.linecolors) xgvis /tmp/RtmpiVHdhY/xgvis-56f32f43 & sh: line 1: xgvis: command not found > > ##> 2) Show lines by hitting "l" with the mouse over the plot. > ##> 3) Examine morsecode labels by hitting "i" and mousing around on the plot. > ##> 3b) Press "r" (on the plot) to switch 3D rotation in xgobi. > ##> 4) Run MDS in 3D by clicking "Run MDS" (in xgvis). > ##> 5) Speed up the optimization by increasing the "Stepsize" with the slider. > ##> The "Stress function" value may go as low as 0.1925 (MM). > ##> 6) When the optimization calms down, click "Run MDS" to toggle MDS off. > ##> 7) Rotate the MDS configuration in 3D {by "r" with mouse over plot}. > ##> 8) Increase the rotation speed with the slider in the top left and > ##> control the rotation direction by dragging the mouse on the plot. > ##> 9) You can check out the initial configuration by > > ## In order to have no color warning : > Mcolors <- unique(morsecodes.colors) > (Mcolors <- paste("*brushColor", 0:(length(Mcolors)-1),": ", Mcolors, sep="")) [1] "*brushColor0: SkyBlue" "*brushColor1: Green" "*brushColor2: Yellow" [4] "*brushColor3: HotPink" "*brushColor4: Red" > > xgobi(morsecodes.pos, collab = morsecodes.col, rowlab = mc.row, + colors = morsecodes.colors, + glyphs = morsecodes.glyphs, + lines = morsecodes.lines, + linecolors = morsecodes.linecolors, + resources= c("*showLines: True", Mcolors)) xgobi -title 'morsecodes.pos' -std mmx /tmp/RtmpiVHdhY/xgobi-mrscd77a4044d & sh: line 1: xgobi: command not found > > ##> This XGobi window will be linked with > ##> the XGvis window for glyph-color brushing and labeling. > > > > ### *