데이터분석/Machine Learning

R을 이용한 다차원 분석 예

늘근이 2016. 1. 10. 13:48
> data("eurodist")
> eurodist
                Athens Barcelona Brussels Calais Cherbourg Cologne Copenhagen Geneva Gibraltar Hamburg Hook of Holland
Barcelona         3313                                                                                                
Brussels          2963      1318                                                                                      
Calais            3175      1326      204                                                                             
Cherbourg         3339      1294      583    460                                                                      
Cologne           2762      1498      206    409       785                                                            
Copenhagen        3276      2218      966   1136      1545     760                                                    
Geneva            2610       803      677    747       853    1662       1418                                         
Gibraltar         4485      1172     2256   2224      2047    2436       3196   1975                                  
Hamburg           2977      2018      597    714      1115     460        460   1118      2897                        
Hook of Holland   3030      1490      172    330       731     269        269    895      2428     550                
Lisbon            4532      1305     2084   2052      1827    2290       2971   1936       676    2671            2280
Lyons             2753       645      690    739       789     714       1458    158      1817    1159             863
Madrid            3949       636     1558   1550      1347    1764       2498   1439       698    2198            1730
Marseilles        2865       521     1011   1059      1101    1035       1778    425      1693    1479            1183
Milan             2282      1014      925   1077      1209     911       1537    328      2185    1238            1098
Munich            2179      1365      747    977      1160     583       1104    591      2565     805             851
Paris             3000      1033      285    280       340     465       1176    513      1971     877             457
Rome               817      1460     1511   1662      1794    1497       2050    995      2631    1751            1683
Stockholm         3927      2868     1616   1786      2196    1403        650   2068      3886     949            1500
Vienna            1991      1802     1175   1381      1588     937       1455   1019      2974    1155            1205
                Lisbon Lyons Madrid Marseilles Milan Munich Paris Rome Stockholm
Barcelona                                                                       
Brussels                                                                        
Calais                                                                          
Cherbourg                                                                       
Cologne                                                                         
Copenhagen                                                                      
Geneva                                                                          
Gibraltar                                                                       
Hamburg                                                                         
Hook of Holland                                                                 
Lisbon                                                                          
Lyons             1178                                                          
Madrid             668  1281                                                    
Marseilles        1762   320   1157                                             
Milan             2250   328   1724        618                                  
Munich            2507   724   2010       1109   331                            
Paris             1799   471   1273        792   856    821                     
Rome              2700  1048   2097       1011   586    946  1476               
Stockholm         3231  2108   3188       2428  2187   1754  1827 2707          
Vienna            2937  1157   2409       1363   898    428  1249 1209      2105
 
> loc <- cmdscale(eurodist)
> loc
                        [,1]        [,2]
Athens           2290.274680  1798.80293
Barcelona        -825.382790   546.81148
Brussels           59.183341  -367.08135
Calais            -82.845973  -429.91466
Cherbourg        -352.499435  -290.90843
Cologne           293.689633  -405.31194
Copenhagen        681.931545 -1108.64478
Geneva             -9.423364   240.40600
Gibraltar       -2048.449113   642.45854
Hamburg           561.108970  -773.36929
Hook of Holland   164.921799  -549.36704
Lisbon          -1935.040811    49.12514
Lyons            -226.423236   187.08779
Madrid          -1423.353697   305.87513
Marseilles       -299.498710   388.80726
Milan             260.878046   416.67381
Munich            587.675679    81.18224
Paris            -156.836257  -211.13911
Rome              709.413282  1109.36665
Stockholm         839.445911 -1836.79055
Vienna            911.230500   205.93020
 
> x <- loc[,1]
> y <- loc[,2]
> plot(x,y,type="n", main="eurodist")
> text(x,y,rownames(loc),cex=0.8)
> abline(v=0, h=0)