Matriz de distancia

Dm(M=D,md=‘e’,s=F,t=F,d=3)
M:Matriz,s:Estandarizar,t:Transponer,d:Dígito decimal
md:Tipo de distancia(‘[c]anberra’,‘[e]uclidean’[def.],‘[max]imum’,‘[man]hattan’,‘[mi]nkowski’)

D=Ip('s4.txt') #Ejemplo sencillo: Puntaje de 4 personas
## File: s4.txt / Class: data.frame / Rows: 4 / Columns: 3
##  
##         v1.English v2.Physics v3.Latin
## i1.Ana   9         14         18      
## i2.Juan 17          7         11      
## i3.Mary 15         13         14      
## i4.Ken   5         18          8
Dm() #Matriz de distancia
##         i1.Ana i2.Juan i3.Mary i4.Ken
## i1.Ana   0.000  12.728   7.280 11.489
## i2.Juan 12.728   0.000   7.000 16.553
## i3.Mary  7.280   7.000   0.000 12.689
## i4.Ken  11.489  16.553  12.689  0.000
D=USArrests[,-3]; Dt(D,10) #Datos:USArrests (-col.3: UrbanPop)
## Class: data.frame / Rows: 50 / Columns: 3
##  
##             Murder Assault Rape
## Alabama     13.2   236     21.2
## Alaska      10.0   263     44.5
## Arizona      8.1   294     31.0
## Arkansas     8.8   190     19.5
## California   9.0   276     40.6
## Colorado     7.9   204     38.7
## Connecticut  3.3   110     11.1
## Delaware     5.9   238     15.8
## Florida     15.4   335     31.9
## Georgia     17.4   211     25.8
D1=Dm(d=1); Dt(D1,6,6) #Matriz de distancia
## Class: matrix, array / Rows: 50 / Columns: 50
##  
##            Alabama Alaska Arizona Arkansas California Colorado
## Alabama     0.0    35.8    59.0    46.2    44.7       36.9    
## Alaska     35.8     0.0    33.9    77.2    13.6       59.3    
## Arizona    59.0    33.9     0.0   104.6    20.4       90.3    
## Arkansas   46.2    77.2   104.6     0.0    88.6       23.8    
## California 44.7    13.6    20.4    88.6     0.0       72.0    
## Colorado   36.9    59.3    90.3    23.8    72.0        0.0
D2=Dm(s=T, d=3); Dt(D2,6,6) #Id.+(s+T:Estandarizar, d:Dígito decimal=3)
## Class: matrix, array / Rows: 50 / Columns: 50
##  
##            Alabama Alaska Arizona Arkansas California Colorado
## Alabama    0.000   2.641  1.735   1.177    2.358      2.285   
## Alaska     2.641   0.000  1.567   2.851    0.506      1.068   
## Arizona    1.735   1.567  0.000   1.776    1.078      1.372   
## Arkansas   1.177   2.851  1.776   0.000    2.503      2.088   
## California 2.358   0.506  1.078   2.503    0.000      0.932   
## Colorado   2.285   1.068  1.372   2.088    0.932      0.000

Dendrograma

gClusterDd(M=D,md=‘e’,mc=‘w’,s=F,t=F,g=0,lx=’‘,ly=’‘,v=F,f=12,m=10,w=F)
M:Matriz,s:Estandarizar,t:Transponer,g:Número de grupos,lx,ly:Rótulos,v:Eje-X vertical,f:Tamaño de letra,m:Margen,w:Blanco y negro
md:Tipo de distancia(’[c]anberra’,‘[e]uclidean’,‘[max]imum’,‘[man]hattan’,‘[mi]nkowski’)
mc:Método de conglomeración (‘[a]verage’,‘[s]ingle’,‘[c]omplete’,‘[w]ard.D2’)

D=Ip('s4.txt') #Ejemplo sencillo: Puntaje de 4 personas
## File: s4.txt / Class: data.frame / Rows: 4 / Columns: 3
##  
##         v1.English v2.Physics v3.Latin
## i1.Ana   9         14         18      
## i2.Juan 17          7         11      
## i3.Mary 15         13         14      
## i4.Ken   5         18          8
Dt(Dm(),5,5) #Matriz de distancia
## Class: matrix, array / Rows: 4 / Columns: 4
##  
##         i1.Ana i2.Juan i3.Mary i4.Ken
## i1.Ana   0.000 12.728   7.280  11.489
## i2.Juan 12.728  0.000   7.000  16.553
## i3.Mary  7.280  7.000   0.000  12.689
## i4.Ken  11.489 16.553  12.689   0.000
gClusterDd() #Dendrograma conglomerado

gClusterDd(g=2) #g:Número de grupos=2

gClusterDd(g=2,lx='Persona',ly='Distancia') #lx,ly:Rótulos

gClusterDd(g=2,lx='Persona',ly='Distancia',m=5) #Margen=2

D=USArrests[,-3]; Dt(D,10) #Datos:USArrests (-col.3: UrbanPop)
## Class: data.frame / Rows: 50 / Columns: 3
##  
##             Murder Assault Rape
## Alabama     13.2   236     21.2
## Alaska      10.0   263     44.5
## Arizona      8.1   294     31.0
## Arkansas     8.8   190     19.5
## California   9.0   276     40.6
## Colorado     7.9   204     38.7
## Connecticut  3.3   110     11.1
## Delaware     5.9   238     15.8
## Florida     15.4   335     31.9
## Georgia     17.4   211     25.8
NS(D,2) #Estandarizar
##                   Murder   Assault      Rape
## Alabama        3.0614129 2.8606035 2.2863928
## Alaska         2.3192522 3.1878759 4.7992679
## Arizona        1.8785943 3.5636331 3.3433102
## Arkansas       2.0409419 2.3030282 2.1030500
## California     2.0873269 3.3454515 4.3786579
## Colorado       1.8322092 2.4727250 4.1737453
## Connecticut    0.7653532 1.3333321 1.1971207
## Delaware       1.3683588 2.8848459 1.7040097
## Florida        3.5716483 4.0606024 3.4403740
## Georgia        4.0354988 2.5575734 2.7824969
## Hawaii         1.2292036 0.5575752 2.1785441
## Idaho          0.6030056 1.4545441 1.5314518
## Illinois       2.4120223 3.0181791 2.5883692
## Indiana        1.6698616 1.3696957 2.2648230
## Iowa           0.5102355 0.6787873 1.2186905
## Kansas         1.3915513 1.3939381 1.9412769
## Kentucky       2.2496746 1.3212109 1.7579341
## Louisiana      3.5716483 3.0181791 2.3942415
## Maine          0.4870430 1.0060597 0.8412200
## Maryland       2.6207549 3.6363603 2.9981943
## Massachusetts  1.0204710 1.8060590 1.7579341
## Michigan       2.8062951 3.0909063 3.7854899
## Minnesota      0.6261981 0.8727265 1.6069459
## Mississippi    3.7339960 3.1393911 1.8442130
## Missouri       2.0873269 2.1575738 3.0413338
## Montana        1.3915513 1.3212109 1.7687189
## Nebraska       0.9972784 1.2363625 1.7795038
## Nevada         2.8294876 3.0545427 4.9610409
## New Hampshire  0.4870430 0.6909085 1.0245628
## New Jersey     1.7162466 1.9272710 2.0275559
## New Mexico     2.6439475 3.4545423 3.4619438
## New York       2.5743699 3.0787851 2.8148515
## North Carolina 3.0150278 4.0848448 1.7363643
## North Dakota   0.1855402 0.5454540 0.7872956
## Ohio           1.6930541 1.4545441 2.3079625
## Oklahoma       1.5307064 1.8303014 2.1569743
## Oregon         1.1364336 1.9272710 3.1599674
## Pennsylvania   1.4611289 1.2848473 1.6069459
## Rhode Island   0.7885457 2.1090890 0.8951443
## South Carolina 3.3397231 3.3818151 2.4265961
## South Dakota   0.8813158 1.0424233 1.3804636
## Tennessee      3.0614129 2.2787858 2.9011305
## Texas          2.9454502 2.4363614 2.7501423
## Utah           0.7421607 1.4545441 2.4697356
## Vermont        0.5102355 0.5818177 1.2079056
## Virginia       1.9713643 1.8909074 2.2324684
## Washington     0.9277009 1.7575742 2.8256364
## West Virginia  1.3219737 0.9818173 1.0029931
## Wisconsin      0.6030056 0.6424237 1.1647661
## Wyoming        1.5770915 1.9515134 1.6824400
Dx=Dm(s=T,d=3); Dt(Dx,6,6) #Matriz de distancia (s:Estandarizar=T, d:Dígito decimal=3)
## Class: matrix, array / Rows: 50 / Columns: 50
##  
##            Alabama Alaska Arizona Arkansas California Colorado
## Alabama    0.000   2.641  1.735   1.177    2.358      2.285   
## Alaska     2.641   0.000  1.567   2.851    0.506      1.068   
## Arizona    1.735   1.567  0.000   1.776    1.078      1.372   
## Arkansas   1.177   2.851  1.776   0.000    2.503      2.088   
## California 2.358   0.506  1.078   2.503    0.000      0.932   
## Colorado   2.285   1.068  1.372   2.088    0.932      0.000
gClusterDd(s=T,lx='States',ly='Distance') #s:Estandarizar=T

gClusterDd(s=T,lx='States',ly='Distance',f=8) #+Tamaño de letra=8

gClusterDd(s=T,lx='States',ly='Distance',f=8,m=5) #Margen=5

gClusterDd(s=T,lx='States',ly='Distance',f=8,m=5,v=T) #v:Eje-X vertical=T

gClusterDd(s=T,lx='States',ly='Distance',f=8,m=5,v=T,w=T) #w:Blanco y negro=T

gClusterDd(s=T,lx='States',ly='Distance',f=8,m=5,g=3) #g:Número de grupos=3

gClusterDd(s=T,lx='States',ly='Distance',f=8,m=5,md='c',g=3) #md:Tipo de distancia=[c]anberra

gClusterDd(s=T,lx='States',ly='Distance',f=8,m=5,md='e',g=3) #md:Tipo de distancia=[e]uclidean(defaut