################################################### ### chunk number 1: ################################################### #line 51 "vignettes/clst/inst/doc/clstDemo.Rnw" figdir <- 'figs_out' dir.create(figdir, showWarnings=FALSE) ################################################### ### chunk number 2: ################################################### #line 177 "vignettes/clst/inst/doc/clstDemo.Rnw" library(clst) data(iris) dmat <- as.matrix(dist(iris[,1:4], method="euclidean")) groups <- iris$Species ################################################### ### chunk number 3: ################################################### #line 190 "vignettes/clst/inst/doc/clstDemo.Rnw" ii <- c(1,125) plot(scaleDistPlot(dmat, groups, indices=ii,O=ii)) ################################################### ### chunk number 4: ################################################### #line 208 "vignettes/clst/inst/doc/clstDemo.Rnw" thresh <- findThreshold(dmat, groups, type="mutinfo") str(thresh) ################################################### ### chunk number 5: ################################################### #line 220 "vignettes/clst/inst/doc/clstDemo.Rnw" thresh2 <- findThreshold(dmat, groups, type="mutinfo", prob=NA) print(thresh2$interval) ################################################### ### chunk number 6: ################################################### #line 231 "vignettes/clst/inst/doc/clstDemo.Rnw" plot(do.call(plotDistances, thresh)) ################################################### ### chunk number 7: ################################################### #line 235 "vignettes/clst/inst/doc/clstDemo.Rnw" plot(do.call(plotDistances, thresh2)) ################################################### ### chunk number 8: ################################################### #line 273 "vignettes/clst/inst/doc/clstDemo.Rnw" ind <- 1 species <- gettextf('I. %s', groups[ind]) cat('class of "unknown" sample is',species) dmat1 <- dmat[-ind,-ind] groups1 <- groups[-ind] dvect1 <- dmat[ind, -ind] cc <- classify(dmat1, groups1, dvect1) printClst(cc) ################################################### ### chunk number 9: ################################################### #line 291 "vignettes/clst/inst/doc/clstDemo.Rnw" ind <- 125 species = gettextf('I. %s', groups[ind]) pp <- pull(dmat, groups, ind) cc <- do.call(classify, pp) cat(paste('class of "unknown" sample is', species)) printClst(cc) ################################################### ### chunk number 10: ################################################### #line 307 "vignettes/clst/inst/doc/clstDemo.Rnw" loo <- lapply(seq_along(groups), function(i){ do.call(classify, pull(dmat, groups, i)) }) matches <- lapply(loo, function(x) rev(x)[[1]]$matches) result <- sapply(matches, paste, collapse='-') table(ifelse(result=='','no match',result),groups) ################################################### ### chunk number 11: ################################################### #line 322 "vignettes/clst/inst/doc/clstDemo.Rnw" confusion <- sapply(matches, length) > 1 no_match <- sapply(matches, length) < 1 plot(scaleDistPlot(dmat, groups, fill=confusion, O=confusion, X=no_match)) ################################################### ### chunk number 12: ################################################### #line 338 "vignettes/clst/inst/doc/clstDemo.Rnw" loo <- lapply(seq_along(groups), function(i){ do.call(classify, c(pull(dmat, groups, i),minScore=0.65)) }) matches <- lapply(loo, function(x) rev(x)[[1]]$matches) result <- sapply(matches, paste, collapse='-') table(ifelse(result=='','no match',result),groups) ################################################### ### chunk number 13: ################################################### #line 351 "vignettes/clst/inst/doc/clstDemo.Rnw" confusion <- sapply(matches, length) > 1 no_match <- sapply(matches, length) < 1 plot(scaleDistPlot(dmat, groups, fill=confusion, O=confusion, X=no_match, indices=no_match)) ################################################### ### chunk number 14: ################################################### #line 368 "vignettes/clst/inst/doc/clstDemo.Rnw" printClst(loo[[118]])