#contoh k-means clustering
TimeLearning<-c(80,130,110,90,120,140,60,50,100,70,120,100,45)
TimePlaying<-c(130,45,90,100,60,30,150,145,90,80,120,40,140)
People<-cbind(TimeLearning,TimePlaying)
People
## TimeLearning TimePlaying
## [1,] 80 130
## [2,] 130 45
## [3,] 110 90
## [4,] 90 100
## [5,] 120 60
## [6,] 140 30
## [7,] 60 150
## [8,] 50 145
## [9,] 100 90
## [10,] 70 80
## [11,] 120 120
## [12,] 100 40
## [13,] 45 140
rownames(People)<-c("Izan","Tiara","Sendy","Jimmy","Kiky","Mega","Ridha","Fian","Kia","Dewi","Sita","Irfan","Boki")
People
## TimeLearning TimePlaying
## Izan 80 130
## Tiara 130 45
## Sendy 110 90
## Jimmy 90 100
## Kiky 120 60
## Mega 140 30
## Ridha 60 150
## Fian 50 145
## Kia 100 90
## Dewi 70 80
## Sita 120 120
## Irfan 100 40
## Boki 45 140
plot(People,cex=2,lwd=4,pch=1)

plot(People,cex=0.1,lwd=0.1,pch=1)
text(People,labels=row.names(People),cex=2)

plot(People,cex=0.1,lwd=0.1,pch=1,asp=1)
text(People,labels=row.names(People),cex=2)

kluster<-kmeans(People,3)
kluster$withinss
## [1] 1343.75 2400.00 937.50
str(kluster)
## List of 9
## $ cluster : Named int [1:13] 3 1 2 2 1 1 3 3 2 2 ...
## ..- attr(*, "names")= chr [1:13] "Izan" "Tiara" "Sendy" "Jimmy" ...
## $ centers : num [1:3, 1:2] 122.5 98 58.8 43.8 96 ...
## ..- attr(*, "dimnames")=List of 2
## .. ..$ : chr [1:3] "1" "2" "3"
## .. ..$ : chr [1:2] "TimeLearning" "TimePlaying"
## $ totss : num 32027
## $ withinss : num [1:3] 1344 2400 938
## $ tot.withinss: num 4681
## $ betweenss : num 27346
## $ size : int [1:3] 4 5 4
## $ iter : int 2
## $ ifault : int 0
## - attr(*, "class")= chr "kmeans"
X1<-c(2,8,9,1,8.5)
X2<-c(4,2,3,5,1)
group<-cbind(X1,X2)
group
## X1 X2
## [1,] 2.0 4
## [2,] 8.0 2
## [3,] 9.0 3
## [4,] 1.0 5
## [5,] 8.5 1
rownames(group)<-c("a","b","c","d","e")
cluster<-kmeans(group,2)
cluster
## K-means clustering with 2 clusters of sizes 3, 2
##
## Cluster means:
## X1 X2
## 1 8.5 2.0
## 2 1.5 4.5
##
## Clustering vector:
## a b c d e
## 2 1 1 2 1
##
## Within cluster sum of squares by cluster:
## [1] 2.5 1.0
## (between_SS / total_SS = 95.0 %)
##
## Available components:
##
## [1] "cluster" "centers" "totss" "withinss"
## [5] "tot.withinss" "betweenss" "size" "iter"
## [9] "ifault"
cluster$withinss #jumlah withinnya per masing" variabel, variansi/jarak antar objek di sebuah kelompok --> sum((x-Xbar)^2+(y-ybar)^2)
## [1] 2.5 1.0
cluster$tot.withinss #jumlah withinnya semua data --> sum(withinss)
## [1] 3.5
cluster$totss #jumlah within semua data
## [1] 69.8
cluster$betweenss #variansi antar cluster=cluster$totss - cluster$tot.withinss
## [1] 66.3
cluster$centers #rata" per masing" variabel pada maisng" cluster
## X1 X2
## 1 8.5 2.0
## 2 1.5 4.5
#kebaikan cluster-->betweenSS/totSS
search()
## [1] ".GlobalEnv" "package:stats" "package:graphics"
## [4] "package:grDevices" "package:utils" "package:datasets"
## [7] "package:methods" "Autoloads" "package:base"
ls(7) #dataset
## [1] "addNextMethod" "allGenerics"
## [3] "allNames" "Arith"
## [5] "as" "as<-"
## [7] "asMethodDefinition" "assignClassDef"
## [9] "assignMethodsMetaData" "balanceMethodsList"
## [11] "body<-" "cacheGenericsMetaData"
## [13] "cacheMetaData" "cacheMethod"
## [15] "callGeneric" "callNextMethod"
## [17] "canCoerce" "cbind2"
## [19] "checkAtAssignment" "checkSlotAssignment"
## [21] "classesToAM" "classLabel"
## [23] "classMetaName" "className"
## [25] "coerce" "coerce<-"
## [27] "Compare" "completeClassDefinition"
## [29] "completeExtends" "completeSubclasses"
## [31] "Complex" "conformMethod"
## [33] "defaultDumpName" "defaultPrototype"
## [35] "doPrimitiveMethod" "dumpMethod"
## [37] "dumpMethods" "el"
## [39] "el<-" "elNamed"
## [41] "elNamed<-" "empty.dump"
## [43] "emptyMethodsList" "evalOnLoad"
## [45] "evalqOnLoad" "evalSource"
## [47] "existsFunction" "existsMethod"
## [49] "extends" "externalRefMethod"
## [51] "finalDefaultMethod" "findClass"
## [53] "findFunction" "findMethod"
## [55] "findMethods" "findMethodSignatures"
## [57] "findUnique" "fixPre1.8"
## [59] "formalArgs" "functionBody"
## [61] "functionBody<-" "generic.skeleton"
## [63] "getAccess" "getAllMethods"
## [65] "getAllSuperClasses" "getClass"
## [67] "getClassDef" "getClasses"
## [69] "getClassName" "getClassPackage"
## [71] "getDataPart" "getExtends"
## [73] "getFunction" "getGeneric"
## [75] "getGenerics" "getGroup"
## [77] "getGroupMembers" "getLoadActions"
## [79] "getMethod" "getMethods"
## [81] "getMethodsForDispatch" "getMethodsMetaData"
## [83] "getPackageName" "getProperties"
## [85] "getPrototype" "getRefClass"
## [87] "getSlots" "getSubclasses"
## [89] "getValidity" "getVirtual"
## [91] "hasArg" "hasLoadAction"
## [93] "hasMethod" "hasMethods"
## [95] "implicitGeneric" "inheritedSlotNames"
## [97] "initFieldArgs" "initialize"
## [99] "initRefFields" "insertClassMethods"
## [101] "insertMethod" "insertSource"
## [103] "is" "isClass"
## [105] "isClassDef" "isClassUnion"
## [107] "isGeneric" "isGrammarSymbol"
## [109] "isGroup" "isRematched"
## [111] "isSealedClass" "isSealedMethod"
## [113] "isVirtualClass" "isXS3Class"
## [115] "kronecker" "languageEl"
## [117] "languageEl<-" "linearizeMlist"
## [119] "listFromMethods" "listFromMlist"
## [121] "loadMethod" "Logic"
## [123] "makeClassRepresentation" "makeExtends"
## [125] "makeGeneric" "makeMethodsList"
## [127] "makePrototypeFromClassDef" "makeStandardGeneric"
## [129] "matchSignature" "Math"
## [131] "Math2" "mergeMethods"
## [133] "metaNameUndo" "method.skeleton"
## [135] "MethodAddCoerce" "methodSignatureMatrix"
## [137] "MethodsList" "MethodsListSelect"
## [139] "methodsPackageMetaName" "missingArg"
## [141] "mlistMetaName" "multipleClasses"
## [143] "new" "newBasic"
## [145] "newClassRepresentation" "newEmptyObject"
## [147] "Ops" "packageSlot"
## [149] "packageSlot<-" "possibleExtends"
## [151] "prohibitGeneric" "promptClass"
## [153] "promptMethods" "prototype"
## [155] "Quote" "rbind2"
## [157] "reconcilePropertiesAndPrototype" "registerImplicitGenerics"
## [159] "rematchDefinition" "removeClass"
## [161] "removeGeneric" "removeMethod"
## [163] "removeMethods" "removeMethodsObject"
## [165] "representation" "requireMethods"
## [167] "resetClass" "resetGeneric"
## [169] "S3Class" "S3Class<-"
## [171] "S3Part" "S3Part<-"
## [173] "sealClass" "seemsS4Object"
## [175] "selectMethod" "selectSuperClasses"
## [177] "setAs" "setClass"
## [179] "setClassUnion" "setDataPart"
## [181] "setGeneric" "setGenericImplicit"
## [183] "setGroupGeneric" "setIs"
## [185] "setLoadAction" "setLoadActions"
## [187] "setMethod" "setOldClass"
## [189] "setPackageName" "setPrimitiveMethods"
## [191] "setRefClass" "setReplaceMethod"
## [193] "setValidity" "show"
## [195] "showClass" "showDefault"
## [197] "showExtends" "showMethods"
## [199] "showMlist" "signature"
## [201] "SignatureMethod" "sigToEnv"
## [203] "slot" "slot<-"
## [205] "slotNames" "slotsFromS3"
## [207] "substituteDirect" "substituteFunctionArgs"
## [209] "Summary" "superClassDepth"
## [211] "testInheritedMethods" "testVirtual"
## [213] "traceOff" "traceOn"
## [215] "tryNew" "unRematchDefinition"
## [217] "validObject" "validSlotNames"
data=datasets::USArrests
dist(data)
## Alabama Alaska Arizona Arkansas California
## Alaska 37.177009
## Arizona 63.008333 46.592489
## Arkansas 46.928137 77.197409 108.851918
## California 55.524769 45.102217 23.194180 97.582017
## Colorado 41.932565 66.475935 90.351148 36.734861 73.197131
## Connecticut 128.206942 159.406556 185.159526 85.028289 169.277110
## Delaware 16.806249 45.182961 58.616380 53.010376 49.291480
## Florida 102.001618 79.974496 41.654532 148.735739 60.980735
## Georgia 25.841827 57.030255 86.037957 25.586129 73.997297
## Hawaii 191.803050 221.193535 248.268967 147.775979 231.071093
## Idaho 116.761980 146.484982 176.817674 70.587038 162.612792
## Illinois 28.454877 42.911653 45.697812 67.770274 32.718802
## Indiana 123.345207 152.804090 181.897801 78.478086 166.229961
## Iowa 180.610105 209.983523 239.991458 134.594948 224.634659
## Kansas 121.519875 151.480197 180.028914 76.753436 164.516747
## Kentucky 127.284170 156.612037 187.690303 81.092848 173.207910
## Louisiana 15.454449 32.348879 48.494639 61.545512 41.635562
## Maine 154.145289 183.897526 214.327413 107.850730 199.931113
## Maryland 64.993615 44.839492 15.015991 111.642913 36.347352
## Massachusetts 91.648513 123.254209 145.875906 54.181178 129.524708
## Michigan 28.485435 28.857755 39.872422 71.100281 27.746351
## Minnesota 164.650964 194.253571 223.088256 119.324641 207.222537
## Mississippi 27.390144 28.635118 52.708728 69.685364 55.683570
## Missouri 59.788293 89.306719 116.467377 24.894377 100.988910
## Montana 127.392621 156.673578 187.540849 81.163107 172.996069
## Nebraska 134.436974 164.114259 193.423602 88.978930 178.100814
## Nevada 37.430469 34.886817 44.797433 74.288694 26.746962
## New Hampshire 179.736196 209.254415 239.255616 133.678308 224.055395
## New Jersey 83.243018 114.735566 135.850396 49.844257 119.041169
## New Mexico 51.643489 33.521933 13.896043 97.931200 24.495102
## New York 33.710829 43.182983 40.853519 73.762118 26.900929
## North Carolina 101.961022 79.376067 57.619615 147.184238 80.332123
## North Dakota 192.416138 221.378590 252.808188 145.855545 238.214462
## Ohio 117.387606 147.373335 174.338177 74.369752 157.998513
## Oklahoma 85.848704 116.429421 143.931407 43.012673 128.779346
## Oregon 78.386861 106.930117 135.672879 36.895122 120.039577
## Pennsylvania 131.085087 161.600897 188.866222 86.990862 172.999364
## Rhode Island 70.338112 103.903802 122.418871 42.185305 107.213106
## South Carolina 44.182915 27.556487 36.890920 89.248866 47.061343
## South Dakota 151.089113 179.948131 211.751576 104.455206 197.524378
## Tennessee 48.347596 77.884530 108.258117 12.614278 94.727662
## Texas 41.566092 72.362214 93.275988 32.744618 77.380230
## Utah 118.502700 148.276094 174.257338 76.438995 157.492635
## Vermont 190.370691 218.290472 251.489264 143.528569 237.435465
## Virginia 80.295330 110.646690 139.424711 36.421560 124.820912
## Washington 92.820472 122.147002 149.297857 51.204785 133.106574
## West Virginia 156.792411 185.640863 218.006078 110.071113 204.253715
## Wisconsin 183.775733 213.575397 242.312381 138.344245 226.457502
## Wyoming 75.507086 106.740105 135.380390 30.987255 121.720335
## Colorado Connecticut Delaware Florida Georgia
## Alaska
## Arizona
## Arkansas
## California
## Colorado
## Connecticut 98.081191
## Delaware 41.477825 128.210179
## Florida 131.405822 226.303005 99.108325
## Georgia 25.093027 104.426529 33.245300 125.766490
## Hawaii 159.179176 64.952367 192.366109 289.428575 167.128005
## Idaho 90.886413 25.280427 119.421313 217.665179 93.116057
## Illinois 47.669068 139.906469 18.151859 86.558708 45.002667
## Indiana 93.615063 16.316250 125.310534 222.923866 98.772871
## Iowa 152.079749 57.595573 182.709989 281.013523 156.445805
## Kansas 92.179716 14.173920 123.165945 221.082722 97.174071
## Kentucky 101.024749 26.343880 130.597435 228.332762 103.041448
## Louisiana 49.974994 140.398077 16.976749 87.670348 38.690567
## Maine 127.900156 37.647443 156.666652 255.152307 130.472564
## Maryland 97.300411 191.161947 63.577984 37.783859 89.505363
## Massachusetts 59.900000 40.165284 89.958324 187.043738 68.762272
## Michigan 51.454835 147.266561 26.531679 80.356269 47.398101
## Minnesota 134.764535 39.746698 166.141656 264.225831 140.327830
## Mississippi 68.664401 153.263955 36.479172 85.390456 51.355428
## Missouri 29.179788 70.695827 61.378905 157.491746 35.571337
## Montana 100.751675 24.746313 130.393136 228.327856 103.302081
## Nebraska 105.668349 17.865050 136.378334 234.464006 110.195735
## Nevada 48.834209 146.551083 35.053245 84.255860 50.567579
## New Hampshire 151.589182 57.043843 181.854695 280.247480 155.665603
## New Jersey 50.420829 51.196680 80.877995 176.897174 60.778286
## New Mexico 81.736222 176.580322 50.089320 51.147238 75.177723
## New York 52.278102 145.268166 24.189461 81.542198 50.643657
## North Carolina 138.977588 229.504009 102.861557 38.527912 127.335973
## North Dakota 165.750928 73.038962 195.272271 293.622751 168.611417
## Ohio 85.817539 15.036289 118.179186 215.466610 92.883637
## Oklahoma 57.099737 43.036031 87.195929 184.983918 61.759858
## Oregon 47.364121 53.242840 80.307223 176.810661 54.050902
## Pennsylvania 101.039596 8.027453 132.003674 229.949581 106.822376
## Rhode Island 43.879494 64.837104 66.208006 163.312461 50.992647
## South Carolina 82.641939 172.206765 48.725148 65.187115 69.194581
## South Dakota 125.302115 40.039231 154.422829 252.438844 127.294776
## Tennessee 28.005892 82.192761 53.343228 148.592867 23.427548
## Texas 14.501034 92.659160 39.665224 134.179917 22.851258
## Utah 85.625522 15.755951 118.514556 215.533849 94.292364
## Vermont 165.047690 76.617361 194.254601 292.020085 166.724923
## Virginia 53.416851 49.307200 82.678716 180.286023 56.028743
## Washington 60.642065 38.334058 93.604327 190.555635 68.590962
## West Virginia 132.360115 47.895720 160.562418 258.460539 133.229651
## Wisconsin 154.115217 58.056696 185.194195 283.423799 159.511880
## Wyoming 52.036718 54.060152 77.934909 176.112606 52.119094
## Hawaii Idaho Illinois Indiana Iowa
## Alaska
## Arizona
## Arkansas
## California
## Colorado
## Connecticut
## Delaware
## Florida
## Georgia
## Hawaii
## Idaho 79.751426
## Illinois 203.099606 132.811445
## Indiana 69.406412 15.407790 137.256111
## Iowa 29.407822 64.137119 195.329286 58.584042
## Kansas 71.100844 13.964240 135.278823 3.929377 60.177487
## Kentucky 70.459705 13.409698 143.599373 14.606163 53.993055
## Louisiana 203.970611 130.433278 17.811232 136.255936 193.966621
## Maine 50.566788 37.672404 170.033320 36.003472 27.879383
## Maryland 254.687573 181.189542 53.593376 187.179192 244.930725
## Massachusetts 103.097139 42.539981 100.495224 41.544314 97.277130
## Michigan 209.833863 138.390968 15.591664 143.065789 201.381355
## Minnesota 31.620405 49.482320 178.213636 41.706834 18.713899
## Mississippi 216.832308 140.041637 41.244394 147.822258 203.972670
## Missouri 132.931148 62.104428 72.315973 65.613108 124.035680
## Montana 69.885120 11.764353 143.447273 13.512957 53.529898
## Nebraska 59.930710 19.904271 148.806787 12.596031 46.609548
## Nevada 207.733603 138.767431 22.366046 142.221658 200.738860
## New Hampshire 31.220666 63.208702 194.607657 58.096988 2.291288
## New Jersey 113.187323 52.822344 90.399336 51.931493 108.241813
## New Mexico 239.726553 166.969608 39.135789 172.481448 230.493557
## New York 208.186095 138.541907 6.236986 142.699755 200.856292
## North Carolina 293.600238 217.443717 96.214188 225.019221 281.504316
## North Dakota 41.335941 75.999013 208.585834 72.757474 17.548789
## Ohio 74.467711 22.692069 129.311136 12.213517 67.439009
## Oklahoma 106.074172 34.736724 99.294713 38.136072 96.130380
## Oregon 114.490043 43.855444 91.729712 46.842075 105.072784
## Pennsylvania 61.237978 23.112334 143.769329 11.662761 52.485903
## Rhode Island 128.628224 63.564534 77.048621 66.187083 121.796716
## South Carolina 235.800975 159.765860 46.295248 167.030207 223.795174
## South Dakota 55.686713 35.219313 167.874953 34.753417 32.385336
## Tennessee 144.385941 70.161599 65.675338 75.708718 133.388005
## Texas 155.296008 86.410069 48.171984 89.551661 147.871194
## Utah 74.139733 27.423530 129.240280 17.135052 68.996812
## Vermont 51.919264 75.346931 207.925660 73.722724 26.249000
## Virginia 111.850302 38.132139 95.202416 43.067157 100.816913
## Washington 99.692979 33.644613 104.698615 33.545193 91.663788
## West Virginia 57.271022 42.185543 174.350738 42.885196 31.068473
## Wisconsin 20.824265 68.151009 197.332410 61.042608 9.508417
## Wyoming 117.377212 41.672533 91.414003 48.562537 105.231412
## Kansas Kentucky Louisiana Maine Maryland
## Alaska
## Arizona
## Arkansas
## California
## Colorado
## Connecticut
## Delaware
## Florida
## Georgia
## Hawaii
## Idaho
## Illinois
## Indiana
## Iowa
## Kansas
## Kentucky 15.766420
## Louisiana 134.394940 140.937220
## Maine 36.989863 28.407921 167.825058
## Maryland 185.337881 191.939600 51.479802 218.699886
## Massachusetts 39.018585 52.125713 102.551499 74.763226 152.659294
## Michigan 141.398798 148.859665 16.652327 175.949680 46.129492
## Minnesota 43.237715 40.199005 177.605124 19.919086 228.528707
## Mississippi 146.023354 150.351588 24.708298 176.939227 48.451316
## Missouri 64.015936 72.298686 71.651657 99.246007 122.059207
## Montana 14.406943 3.834058 141.035457 27.733914 191.924595
## Nebraska 13.789126 13.349157 147.582858 23.717715 198.508665
## Nevada 140.770878 148.923940 28.472443 176.131343 53.217009
## New Hampshire 59.594127 53.141321 193.137723 26.530925 244.109668
## New Jersey 49.674943 62.293980 93.298231 85.843404 143.042686
## New Mexico 170.716051 177.630318 37.762548 204.553123 15.890249
## New York 140.757309 149.261515 21.417283 175.732439 49.798896
## North Carolina 223.108964 228.131388 90.708158 254.439973 44.640565
## North Dakota 74.333909 65.728304 206.240563 38.664454 257.069057
## Ohio 10.920165 26.110726 129.569479 46.443514 180.335687
## Oklahoma 36.115924 45.202876 98.439220 71.288779 149.281379
## Oregon 45.452173 54.009629 90.893674 80.635538 141.153144
## Pennsylvania 11.256109 20.555291 143.600487 32.218783 194.556958
## Rhode Island 63.425941 74.523084 80.020060 97.872059 129.300657
## South Carolina 165.259826 170.224939 35.001286 196.957813 28.977578
## South Dakota 36.247483 25.001200 165.023998 8.537564 215.780560
## Tennessee 74.222975 80.091260 61.619234 107.596561 112.305031
## Texas 87.710547 96.652160 50.181471 123.250355 99.886185
## Utah 15.901258 31.477135 130.331616 49.388460 180.716961
## Vermont 75.535952 64.832554 204.578200 39.969613 255.122265
## Virginia 41.273963 48.485049 93.315915 75.368229 144.257582
## Washington 31.941196 43.214581 104.933122 68.338642 155.296008
## West Virginia 44.280696 31.906112 170.919572 12.775367 221.627187
## Wisconsin 62.509199 58.417977 196.748062 33.678628 247.739157
## Wyoming 46.458584 52.696300 88.867992 79.043849 139.782295
## Massachusetts Michigan Minnesota Mississippi Missouri
## Alaska
## Arizona
## Arkansas
## California
## Colorado
## Connecticut
## Delaware
## Florida
## Georgia
## Hawaii
## Idaho
## Illinois
## Indiana
## Iowa
## Kansas
## Kentucky
## Louisiana
## Maine
## Maryland
## Massachusetts
## Michigan 108.488386
## Minnesota 79.340091 184.524795
## Mississippi 117.976820 35.440090 188.778706
## Missouri 35.053816 77.473996 107.091456 86.084958
## Montana 51.250073 148.808266 39.384515 150.610425 72.098821
## Nebraska 52.326380 154.789535 30.349959 158.469555 77.453083
## Nevada 107.554312 13.297368 183.527818 47.627933 76.968045
## New Hampshire 96.729158 200.707150 18.828701 202.982167 123.427307
## New Jersey 11.456439 98.634578 90.195898 110.016272 28.511752
## New Mexico 137.911711 30.421867 213.907760 39.988623 107.097946
## New York 105.673696 15.066519 183.630063 43.531598 77.722712
## North Carolina 192.400624 89.032634 266.032949 78.074388 161.457146
## North Dakota 112.209447 214.244090 35.698319 214.769947 137.364661
## Ohio 31.231715 135.781921 49.481411 142.751287 58.635569
## Oklahoma 17.650212 105.405218 79.285686 111.079521 28.390139
## Oregon 24.356724 96.697880 88.216778 103.938828 19.698223
## Pennsylvania 44.984108 150.488139 34.712534 155.864942 73.295157
## Rhode Island 26.343880 86.740590 104.350611 96.502487 27.062335
## South Carolina 135.674021 37.630440 208.249010 21.167192 103.666050
## South Dakota 74.710173 173.113200 25.349951 173.492882 96.711943
## Tennessee 48.854887 69.155260 117.299829 73.283354 15.502580
## Texas 53.689198 55.177169 130.573198 68.863053 25.494705
## Utah 30.182777 135.974446 50.638424 144.281149 59.377858
## Vermont 114.196541 212.796194 41.784447 211.879730 136.672016
## Virginia 23.857284 100.709086 84.452827 105.074830 24.279621
## Washington 16.067669 110.660833 74.211724 118.601096 33.570821
## West Virginia 82.405643 179.464760 29.160933 178.544112 103.624804
## Wisconsin 98.033107 203.835080 19.437592 207.706379 126.430692
## Wyoming 27.843312 97.161412 89.298936 99.743371 23.507446
## Montana Nebraska Nevada New Hampshire New Jersey
## Alaska
## Arizona
## Arkansas
## California
## Colorado
## Connecticut
## Delaware
## Florida
## Georgia
## Hawaii
## Idaho
## Illinois
## Indiana
## Iowa
## Kansas
## Kentucky
## Louisiana
## Maine
## Maryland
## Massachusetts
## Michigan
## Minnesota
## Mississippi
## Missouri
## Montana
## Nebraska 11.528226
## Nevada 148.820697 154.251937
## New Hampshire 52.686051 45.987390 200.210539
## New Jersey 61.674306 63.189398 97.344132 107.738480
## New Mexico 177.596875 183.974917 37.467986 229.732997 128.179132
## New York 149.111032 154.332109 20.645096 200.163833 95.399057
## North Carolina 228.247870 235.774999 97.034272 280.505561 183.462939
## North Dakota 65.474041 60.579617 214.115973 17.161876 123.275342
## Ohio 25.133444 22.934908 134.495985 67.071976 41.518309
## Oklahoma 44.747290 49.543314 105.249038 95.448939 22.518437
## Oregon 53.512802 58.636166 95.797599 104.522151 24.505102
## Pennsylvania 19.296114 11.070682 149.663021 51.998077 55.806989
## Rhode Island 73.846936 76.661920 87.285337 121.050114 18.848077
## South Carolina 170.390053 177.941030 48.734895 222.863837 127.057821
## South Dakota 24.714368 23.641912 173.276657 31.237477 85.521693
## Tennessee 80.243941 87.134207 70.326453 132.649802 42.898135
## Texas 96.543772 101.373369 54.977268 147.242521 43.794749
## Utah 30.001500 26.271087 134.311615 68.744236 40.453059
## Vermont 64.834250 62.036280 212.903828 25.688519 125.119143
## Virginia 48.308798 54.334888 100.964251 100.081966 26.264425
## Washington 42.379712 45.433248 109.417914 91.189363 22.766642
## West Virginia 32.101402 31.996875 179.983721 29.631065 93.151167
## Wisconsin 57.861213 49.521510 202.872374 10.860018 108.867075
## Wyoming 52.481235 59.093654 98.363205 104.361391 29.250641
## New Mexico New York North Carolina North Dakota
## Alaska
## Arizona
## Arkansas
## California
## Colorado
## Connecticut
## Delaware
## Florida
## Georgia
## Hawaii
## Idaho
## Illinois
## Indiana
## Iowa
## Kansas
## Kentucky
## Louisiana
## Maine
## Maryland
## Massachusetts
## Michigan
## Minnesota
## Mississippi
## Missouri
## Montana
## Nebraska
## Nevada
## New Hampshire
## New Jersey
## New Mexico
## New York 35.399011
## North Carolina 59.896244 93.132218
## North Dakota 242.906155 214.253425 292.388919
## Ohio 165.472959 134.586515 219.202144 82.626025
## Oklahoma 134.645646 104.835395 187.566442 109.576138
## Oregon 126.234266 97.132281 180.021804 118.430613
## Pennsylvania 179.907893 149.159244 232.672151 67.771749
## Rhode Island 115.067111 82.323326 168.777961 136.006470
## South Carolina 24.923082 45.747678 58.445872 234.921263
## South Dakota 201.633951 173.594873 251.190227 41.487950
## Tennessee 97.776684 71.344586 150.045593 145.643125
## Texas 84.860179 53.365907 140.746048 161.569954
## Utah 165.761515 134.404799 220.127872 84.676561
## Vermont 241.110867 213.666141 289.535231 13.044922
## Virginia 129.724207 100.841063 182.006621 113.669917
## Washington 140.351594 110.001909 194.501954 105.869967
## West Virginia 207.676022 180.137170 256.264570 36.728871
## Wisconsin 233.176178 202.749451 285.014473 23.737944
## Wyoming 125.576311 97.230345 176.747532 117.545268
## Ohio Oklahoma Oregon Pennsylvania Rhode Island
## Alaska
## Arizona
## Arkansas
## California
## Colorado
## Connecticut
## Delaware
## Florida
## Georgia
## Hawaii
## Idaho
## Illinois
## Indiana
## Iowa
## Kansas
## Kentucky
## Louisiana
## Maine
## Maryland
## Massachusetts
## Michigan
## Minnesota
## Mississippi
## Missouri
## Montana
## Nebraska
## Nevada
## New Hampshire
## New Jersey
## New Mexico
## New York
## North Carolina
## North Dakota
## Ohio
## Oklahoma 31.819019
## Oregon 40.659193 12.424975
## Pennsylvania 15.755951 45.465371 55.166294
## Rhode Island 56.980874 32.204503 32.684094 70.006928
## South Carolina 161.436117 129.811748 122.055274 175.009628 113.440028
## South Dakota 46.284015 69.380689 78.015768 33.758851 97.613575
## Tennessee 70.321121 39.257738 31.299361 84.170125 37.709415
## Texas 81.436908 52.071681 44.813837 96.136986 34.063617
## Utah 6.637771 33.540572 41.639524 18.264994 56.375527
## Vermont 84.634804 109.552727 117.817231 70.671777 137.516726
## Virginia 37.972753 7.355270 10.579225 51.180856 32.859854
## Washington 25.747427 10.305338 15.569843 40.681445 36.847931
## West Virginia 54.460720 76.526466 85.256319 41.781814 104.686628
## Wisconsin 68.588993 98.532431 107.631501 53.623689 122.836843
## Wyoming 44.044182 13.542526 15.630099 56.300444 31.029824
## South Carolina South Dakota Tennessee Texas
## Alaska
## Arizona
## Arkansas
## California
## Colorado
## Connecticut
## Delaware
## Florida
## Georgia
## Hawaii
## Idaho
## Illinois
## Indiana
## Iowa
## Kansas
## Kentucky
## Louisiana
## Maine
## Maryland
## Massachusetts
## Michigan
## Minnesota
## Mississippi
## Missouri
## Montana
## Nebraska
## Nevada
## New Hampshire
## New Jersey
## New Mexico
## New York
## North Carolina
## North Dakota
## Ohio
## Oklahoma
## Oregon
## Pennsylvania
## Rhode Island
## South Carolina
## South Dakota 193.557356
## Tennessee 91.775814 104.341602
## Texas 84.379441 121.204373 24.742878
## Utah 162.574906 49.833423 71.979164 81.596630
## Vermont 232.149801 40.225862 143.862747 161.331150
## Virginia 124.064701 72.859454 33.174237 48.525045
## Washington 136.758364 66.667833 46.153331 57.106742
## West Virginia 198.833926 8.766984 110.521536 128.032965
## Wisconsin 227.323844 39.184691 136.548782 149.726751
## Wyoming 119.051963 76.595300 29.977492 46.182464
## Utah Vermont Virginia Washington West Virginia
## Alaska
## Arizona
## Arkansas
## California
## Colorado
## Connecticut
## Delaware
## Florida
## Georgia
## Hawaii
## Idaho
## Illinois
## Indiana
## Iowa
## Kansas
## Kentucky
## Louisiana
## Maine
## Maryland
## Massachusetts
## Michigan
## Minnesota
## Mississippi
## Missouri
## Montana
## Nebraska
## Nevada
## New Hampshire
## New Jersey
## New Mexico
## New York
## North Carolina
## North Dakota
## Ohio
## Oklahoma
## Oregon
## Pennsylvania
## Rhode Island
## South Carolina
## South Dakota
## Tennessee
## Texas
## Utah
## Vermont 87.326342
## Virginia 40.223501 112.937770
## Washington 26.182628 106.387217 16.477257
## West Virginia 58.251266 33.968515 79.616581 74.434535
## Wisconsin 69.510934 34.370336 103.686161 93.552766 39.049456
## Wyoming 46.338429 116.591252 7.930952 23.349518 82.957218
## Wisconsin
## Alaska
## Arizona
## Arkansas
## California
## Colorado
## Connecticut
## Delaware
## Florida
## Georgia
## Hawaii
## Idaho
## Illinois
## Indiana
## Iowa
## Kansas
## Kentucky
## Louisiana
## Maine
## Maryland
## Massachusetts
## Michigan
## Minnesota
## Mississippi
## Missouri
## Montana
## Nebraska
## Nevada
## New Hampshire
## New Jersey
## New Mexico
## New York
## North Carolina
## North Dakota
## Ohio
## Oklahoma
## Oregon
## Pennsylvania
## Rhode Island
## South Carolina
## South Dakota
## Tennessee
## Texas
## Utah
## Vermont
## Virginia
## Washington
## West Virginia
## Wisconsin
## Wyoming 108.354418
hc.ave=hclust(dist(data),method = "ave")
hc.sing=hclust(dist(data),method = "single")
hc.comp=hclust(dist(data),method = "complete")
hc.ave
##
## Call:
## hclust(d = dist(data), method = "ave")
##
## Cluster method : average
## Distance : euclidean
## Number of objects: 50
hc.sing
##
## Call:
## hclust(d = dist(data), method = "single")
##
## Cluster method : single
## Distance : euclidean
## Number of objects: 50
hc.comp
##
## Call:
## hclust(d = dist(data), method = "complete")
##
## Cluster method : complete
## Distance : euclidean
## Number of objects: 50
#average linkage=berdasarkan rata" jarak
#single linkage = berdasarkan jarak terpendek
#complete linkage = berdasarkan jarak ter jauh
plot(hc.ave)

plot(hc.ave, hang=-1) #merapikan panjang garis

plot(hc.sing, hang=-1)
