Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
67 views
%r library(cluster) flea <- read.table('flea.tsv', header=TRUE, sep="\t") str(flea) flea.st <- scale(flea[, 1:2]) flea.dist <- daisy(flea)
'data.frame': 74 obs. of 3 variables: $ Width : int 150 147 144 144 153 140 151 143 144 142 ... $ Angle : int 15 13 14 16 13 15 14 14 14 15 ... $ Species: Factor w/ 3 levels "Con","Hei","Hep": 1 1 1 1 1 1 1 1 1 1 ...
%r library(aplpack) faces(flea[, 1:2], labels=as.factor(flea$Species))
effect of variables: modified item Var "height of face " "Width" "width of face " "Angle" "structure of face" "Width" "height of mouth " "Angle" "width of mouth " "Width" "smiling " "Angle" "height of eyes " "Width" "width of eyes " "Angle" "height of hair " "Width" "width of hair " "Angle" "style of hair " "Width" "height of nose " "Angle" "width of nose " "Width" "width of ear " "Angle" "height of ear " "Width"
%r flea.a <- agnes(flea[, 1:2], diss=FALSE, metric="ward", stand=TRUE, trace.lev=1) plot(flea.a)
C agnes(n=74, method = 1, ..): 73 merging steps
%r flea.k <- kmeans(flea[, 1:2], 3, nstart=20) table(flea.k$cluster, flea$Species)
Con Hei Hep 1 0 30 3 2 6 1 19 3 15 0 0
%r flea.f <- fanny(flea[, 1:2], 3) plot(flea.f) table(flea.f$cluster, flea$Species)
Con Hei Hep 1 17 0 2 2 4 2 18 3 0 29 2