# # # R代码从装饰图案的clstDemo来源。Rnw“# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #代码块1号:clstDemo。Rnw: 55-57 # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # figdir < - figs_out dir。创建(figdir showWarnings = FALSE) # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #代码块2号:clstDemo。Rnw: 181 - 185 # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #库(凯)数据(iris)质素< -。矩阵(dist(虹膜[1:4],方法=“欧几里得”))团体<——虹膜物种美金# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #代码块3号:clstDemo。Rnw: 194 - 196 # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # 2 < - c(1125)情节(scaleDistPlot(质素、组指数= 2,O = 2)) # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #代码块数量4:clstDemo。Rnw: 212 - 214 # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #打<——findThreshold(质素、组类型=“mutinfo”) str(打)# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #代码块5号:clstDemo。Rnw: 224 - 226 # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # thresh2 <——findThreshold(质素、组类型=“mutinfo”,概率= NA)打印(thresh2间隔美元)# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #代码块6号:clstDemo。Rnw: 235 - 236 # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #情节(做的。调用(plotDistances打))# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #代码块7号:clstDemo。Rnw: 239 - 240 # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #情节(做的。调用(plotDistances thresh2)) # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #代码块8号:clstDemo。Rnw: 277 - 285 # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #印第安纳< - 1种< - gettextf(”我。% s的,猫组(印第安纳州))(“未知”的示例,物种)dmat1 < -质素(印第安纳州,印第安纳州]groups1 < -组(印第安纳州)dvect1 < -质素(印第安纳州,印第安纳州]cc <——分类(dmat1、groups1 dvect1) printClst (cc) # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #代码块9号:clstDemo。Rnw: 295 - 301 # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #印第安纳< - 125 = gettextf(“我的物种。% s,组(印第安纳州))页< -拉(质素、组、印第安纳州)cc < -。call(classify, pp) cat(paste('class of "unknown" sample is', species)) printClst(cc) ################################################### ### code chunk number 10: clstDemo.Rnw:311-317 ################################################### 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) ################################################### ### code chunk number 11: clstDemo.Rnw:326-329 ################################################### confusion <- sapply(matches, length) > 1 no_match <- sapply(matches, length) < 1 plot(scaleDistPlot(dmat, groups, fill=confusion, O=confusion, X=no_match)) ################################################### ### code chunk number 12: clstDemo.Rnw:342-350 ################################################### 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) ################################################### ### code chunk number 13: clstDemo.Rnw:355-359 ################################################### 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)) ################################################### ### code chunk number 14: clstDemo.Rnw:372-373 ################################################### printClst(loo[[118]])