head(d1)
summary(d1)
##      ...1               ...2             Country         
##  Length:312         Length:312         Length:312        
##  Class :character   Class :character   Class :character  
##  Mode  :character   Mode  :character   Mode  :character  
##                                                          
##                                                          
##                                                          
##  Meal, Inexpensive Restaurant
##  Min.   : 1.490              
##  1st Qu.: 4.348              
##  Median : 6.225              
##  Mean   : 7.775              
##  3rd Qu.:11.000              
##  Max.   :23.120              
##  Meal for 2 People, Mid-range Restaurant, Three-course
##  Min.   :  7.59                                       
##  1st Qu.: 20.91                                       
##  Median : 30.00                                       
##  Mean   : 35.46                                       
##  3rd Qu.: 49.47                                       
##  Max.   :109.16                                       
##  McMeal at McDonalds (or Equivalent Combo Meal) Milk (regular), (1 liter)
##  Min.   : 2.670                                 Min.   :0.3900           
##  1st Qu.: 4.050                                 1st Qu.:0.7000           
##  Median : 5.050                                 Median :0.8950           
##  Mean   : 5.627                                 Mean   :0.9962           
##  3rd Qu.: 7.000                                 3rd Qu.:1.1600           
##  Max.   :12.970                                 Max.   :2.6400           
##  Loaf of Fresh White Bread (500g) Eggs (regular) (12)
##  Min.   :0.10                     Min.   :0.750      
##  1st Qu.:0.54                     1st Qu.:1.380      
##  Median :1.05                     Median :1.775      
##  Mean   :1.20                     Mean   :1.916      
##  3rd Qu.:1.69                     3rd Qu.:2.450      
##  Max.   :3.33                     Max.   :5.330      
##  One-way Ticket (Local Transport) Monthly Pass (Regular Price)
##  Min.   :0.100                    Min.   :  3.16              
##  1st Qu.:0.410                    1st Qu.: 17.05              
##  Median :0.900                    Median : 29.71              
##  Mean   :1.201                    Mean   : 40.33              
##  3rd Qu.:2.000                    3rd Qu.: 57.09              
##  Max.   :4.000                    Max.   :167.34              
##  Gasoline (1 liter) Volkswagen Golf Apartment (1 bedroom) in City Centre
##  Min.   :0.390      Min.   : 9343   Min.   : 138.3                      
##  1st Qu.:0.880      1st Qu.:16302   1st Qu.: 335.9                      
##  Median :1.000      Median :18626   Median : 515.0                      
##  Mean   :1.055      Mean   :19792   Mean   : 717.8                      
##  3rd Qu.:1.282      3rd Qu.:22000   3rd Qu.: 970.3                      
##  Max.   :1.960      Max.   :76599   Max.   :3131.1                      
##  Basic (Electricity, Heating, Cooling, Water, Garbage) for 85m2 Apartment
##  Min.   : 18.56                                                          
##  1st Qu.: 61.65                                                          
##  Median : 98.22                                                          
##  Mean   :102.64                                                          
##  3rd Qu.:138.77                                                          
##  Max.   :265.52                                                          
##  Internet (60 Mbps or More, Unlimited Data, Cable/ADSL)
##  Min.   : 4.44                                         
##  1st Qu.:12.81                                         
##  Median :26.47                                         
##  Mean   :29.62                                         
##  3rd Qu.:43.28                                         
##  Max.   :93.29                                         
##  1 Pair of Nike Running Shoes (Mid-Range) 1 Pair of Men Leather Business Shoes
##  Min.   : 38.55                           Min.   : 28.05                      
##  1st Qu.: 65.48                           1st Qu.: 69.49                      
##  Median : 73.09                           Median : 83.57                      
##  Mean   : 73.66                           Mean   : 83.01                      
##  3rd Qu.: 82.64                           3rd Qu.: 96.00                      
##  Max.   :126.37                           Max.   :171.22                      
##  Price per Square Meter to Buy Apartment in City Centre
##  Min.   :  573.5                                       
##  1st Qu.: 1415.4                                       
##  Median : 2378.8                                       
##  Mean   : 3884.9                                       
##  3rd Qu.: 5042.5                                       
##  Max.   :27720.2                                       
##  Average Monthly Net Salary (After Tax)
##  Min.   : 163.9                        
##  1st Qu.: 463.6                        
##  Median : 852.0                        
##  Mean   :1409.4                        
##  3rd Qu.:2340.0                        
##  Max.   :6532.2                        
##  Mortgage Interest Rate in Percentages (%), Yearly, for 20 Years Fixed-Rate
##  Min.   : 1.380                                                            
##  1st Qu.: 3.560                                                            
##  Median : 4.700                                                            
##  Mean   : 7.023                                                            
##  3rd Qu.: 9.450                                                            
##  Max.   :48.690                                                            
##  Rice (white), (1kg) Toyota Corolla 1.6l 97kW Comfort (Or Equivalent New Car)
##  Min.   :0.520       Min.   :11164                                           
##  1st Qu.:0.910       1st Qu.:17448                                           
##  Median :1.130       Median :19227                                           
##  Mean   :1.521       Mean   :20415                                           
##  3rd Qu.:1.820       3rd Qu.:21455                                           
##  Max.   :5.700       Max.   :67345                                           
##  Preschool (or Kindergarten), Full Day, Private, Monthly for 1 Child
##  Min.   :  37.06                                                    
##  1st Qu.: 167.16                                                    
##  Median : 274.44                                                    
##  Mean   : 436.19                                                    
##  3rd Qu.: 533.43                                                    
##  Max.   :2194.64                                                    
##  International Primary School, Yearly for 1 Child
##  Min.   :  788                                   
##  1st Qu.: 3591                                   
##  Median : 6093                                   
##  Mean   : 7890                                   
##  3rd Qu.:10150                                   
##  Max.   :34442
colnames(d1) 
##  [1] "...1"                                                                      
##  [2] "...2"                                                                      
##  [3] "Country"                                                                   
##  [4] "Meal, Inexpensive Restaurant"                                              
##  [5] "Meal for 2 People, Mid-range Restaurant, Three-course"                     
##  [6] "McMeal at McDonalds (or Equivalent Combo Meal)"                            
##  [7] "Milk (regular), (1 liter)"                                                 
##  [8] "Loaf of Fresh White Bread (500g)"                                          
##  [9] "Eggs (regular) (12)"                                                       
## [10] "One-way Ticket (Local Transport)"                                          
## [11] "Monthly Pass (Regular Price)"                                              
## [12] "Gasoline (1 liter)"                                                        
## [13] "Volkswagen Golf"                                                           
## [14] "Apartment (1 bedroom) in City Centre"                                      
## [15] "Basic (Electricity, Heating, Cooling, Water, Garbage) for 85m2 Apartment"  
## [16] "Internet (60 Mbps or More, Unlimited Data, Cable/ADSL)"                    
## [17] "1 Pair of Nike Running Shoes (Mid-Range)"                                  
## [18] "1 Pair of Men Leather Business Shoes"                                      
## [19] "Price per Square Meter to Buy Apartment in City Centre"                    
## [20] "Average Monthly Net Salary (After Tax)"                                    
## [21] "Mortgage Interest Rate in Percentages (%), Yearly, for 20 Years Fixed-Rate"
## [22] "Rice (white), (1kg)"                                                       
## [23] "Toyota Corolla 1.6l 97kW Comfort (Or Equivalent New Car)"                  
## [24] "Preschool (or Kindergarten), Full Day, Private, Monthly for 1 Child"       
## [25] "International Primary School, Yearly for 1 Child"
names(d1) = c("City.Country", "City", "Country", "InexpensiveMeal", "ExpensiveMeal", "McDonaldsMeal", "Milk", "Bread", "Eggs", "LocalTransport", "MonthlyPass", "Gasoline", "Car.VWGolf", "AptRent", "Utilities", "Internet", "SportsShoes", "FormalShoes", "AptCostperSqM", "MonthlySalary", "MortgageRate", "Rice", "ToyotaCorolla", "PreschoolCost", "IntlSchoolCost" )

summary(d1)
##  City.Country           City             Country          InexpensiveMeal 
##  Length:312         Length:312         Length:312         Min.   : 1.490  
##  Class :character   Class :character   Class :character   1st Qu.: 4.348  
##  Mode  :character   Mode  :character   Mode  :character   Median : 6.225  
##                                                           Mean   : 7.775  
##                                                           3rd Qu.:11.000  
##                                                           Max.   :23.120  
##  ExpensiveMeal    McDonaldsMeal         Milk            Bread     
##  Min.   :  7.59   Min.   : 2.670   Min.   :0.3900   Min.   :0.10  
##  1st Qu.: 20.91   1st Qu.: 4.050   1st Qu.:0.7000   1st Qu.:0.54  
##  Median : 30.00   Median : 5.050   Median :0.8950   Median :1.05  
##  Mean   : 35.46   Mean   : 5.627   Mean   :0.9962   Mean   :1.20  
##  3rd Qu.: 49.47   3rd Qu.: 7.000   3rd Qu.:1.1600   3rd Qu.:1.69  
##  Max.   :109.16   Max.   :12.970   Max.   :2.6400   Max.   :3.33  
##       Eggs       LocalTransport   MonthlyPass        Gasoline    
##  Min.   :0.750   Min.   :0.100   Min.   :  3.16   Min.   :0.390  
##  1st Qu.:1.380   1st Qu.:0.410   1st Qu.: 17.05   1st Qu.:0.880  
##  Median :1.775   Median :0.900   Median : 29.71   Median :1.000  
##  Mean   :1.916   Mean   :1.201   Mean   : 40.33   Mean   :1.055  
##  3rd Qu.:2.450   3rd Qu.:2.000   3rd Qu.: 57.09   3rd Qu.:1.282  
##  Max.   :5.330   Max.   :4.000   Max.   :167.34   Max.   :1.960  
##    Car.VWGolf       AptRent         Utilities         Internet    
##  Min.   : 9343   Min.   : 138.3   Min.   : 18.56   Min.   : 4.44  
##  1st Qu.:16302   1st Qu.: 335.9   1st Qu.: 61.65   1st Qu.:12.81  
##  Median :18626   Median : 515.0   Median : 98.22   Median :26.47  
##  Mean   :19792   Mean   : 717.8   Mean   :102.64   Mean   :29.62  
##  3rd Qu.:22000   3rd Qu.: 970.3   3rd Qu.:138.77   3rd Qu.:43.28  
##  Max.   :76599   Max.   :3131.1   Max.   :265.52   Max.   :93.29  
##   SportsShoes      FormalShoes     AptCostperSqM     MonthlySalary   
##  Min.   : 38.55   Min.   : 28.05   Min.   :  573.5   Min.   : 163.9  
##  1st Qu.: 65.48   1st Qu.: 69.49   1st Qu.: 1415.4   1st Qu.: 463.6  
##  Median : 73.09   Median : 83.57   Median : 2378.8   Median : 852.0  
##  Mean   : 73.66   Mean   : 83.01   Mean   : 3884.9   Mean   :1409.4  
##  3rd Qu.: 82.64   3rd Qu.: 96.00   3rd Qu.: 5042.5   3rd Qu.:2340.0  
##  Max.   :126.37   Max.   :171.22   Max.   :27720.2   Max.   :6532.2  
##   MortgageRate         Rice       ToyotaCorolla   PreschoolCost    
##  Min.   : 1.380   Min.   :0.520   Min.   :11164   Min.   :  37.06  
##  1st Qu.: 3.560   1st Qu.:0.910   1st Qu.:17448   1st Qu.: 167.16  
##  Median : 4.700   Median :1.130   Median :19227   Median : 274.44  
##  Mean   : 7.023   Mean   :1.521   Mean   :20415   Mean   : 436.19  
##  3rd Qu.: 9.450   3rd Qu.:1.820   3rd Qu.:21455   3rd Qu.: 533.43  
##  Max.   :48.690   Max.   :5.700   Max.   :67345   Max.   :2194.64  
##  IntlSchoolCost 
##  Min.   :  788  
##  1st Qu.: 3591  
##  Median : 6093  
##  Mean   : 7890  
##  3rd Qu.:10150  
##  Max.   :34442
head(d1)
tail(d1)
colnames(d1)
##  [1] "City.Country"    "City"            "Country"         "InexpensiveMeal"
##  [5] "ExpensiveMeal"   "McDonaldsMeal"   "Milk"            "Bread"          
##  [9] "Eggs"            "LocalTransport"  "MonthlyPass"     "Gasoline"       
## [13] "Car.VWGolf"      "AptRent"         "Utilities"       "Internet"       
## [17] "SportsShoes"     "FormalShoes"     "AptCostperSqM"   "MonthlySalary"  
## [21] "MortgageRate"    "Rice"            "ToyotaCorolla"   "PreschoolCost"  
## [25] "IntlSchoolCost"
d1
d1_meal <- d1$InexpensiveMeal

table(d1_meal)
## d1_meal
##  1.49  1.52  1.78   1.9  1.92  1.94  1.99  2.53  2.54  2.62  2.81  2.87  3.06 
##     2     3     3     5     1     2     1     5     2     3     3     2     1 
##  3.16  3.26   3.3  3.38  3.56  3.57  3.58  3.59  3.61  3.75   3.8  3.82  3.91 
##     3     2     2     1     3     1     1     5     3     3    11     6     2 
##   4.1  4.43  4.45   4.5  4.56  4.58  4.67   4.7  4.72  4.77  4.84  4.87     5 
##     2     2     3     1     3     1     3     3     3     2     1     3     1 
##   5.1  5.23  5.25  5.27  5.39  5.63  5.65  5.72  5.75  5.78  5.88   5.9  5.91 
##     4     7     1     1     1     1     1     3     1     2     1     2     8 
##  5.95  5.99     6  6.12  6.14  6.18  6.27  6.28  6.29  6.34  6.42  6.58  6.72 
##     4     5     3     3     1     3     2     2     3     3     2     3     1 
##  6.94     7  7.33  7.34  7.47     8  8.19  8.33  8.41  8.47   8.5  8.75   8.8 
##     2     6     2     1     2     4     1     1     3     2     3     3     3 
##  8.91  8.93  8.98    10 10.22 10.31 10.45 10.77    11 11.19  11.4 11.69 11.81 
##     2     3     3     7     3     4     3     2     4     3     3     1     3 
## 11.95    12 12.05 12.38 12.43 12.58    13 13.47 13.48 13.75    15 15.54 15.56 
##     1     5     1     3     3     2     1     6     8     3    12     3     3 
## 15.95  17.4 17.49 17.96 17.97  18.7 23.12 
##     2     2     2     3     2     1     3
#plot(d1_meal)

#plot (density(d1_meal))

#dotchart(d1_meal, cex = 0.7, main="Inexpesive Meal Price", xlab = "Meal Price")

#Bread and Milk
d1_MB = ggplot(d1, aes(x=Milk, y = Bread, color = City.Country)) +
  geom_point() + 
  labs(x = "Price of Milk", y = "Price of Bread", title = "Prices of Bread and Milk")+
geom_smooth(method = "lm", color = "blue") +
    theme_fivethirtyeight()
d1_MB_1 <- ggplotly(d1_MB)
## Warning: plotly.js does not (yet) support horizontal legend items 
## You can track progress here: 
## https://github.com/plotly/plotly.js/issues/53
d1_MB_1
#Cost of Cars
d1_VT = ggplot(d1, aes(x=Car.VWGolf, y = ToyotaCorolla, color = City.Country)) +
  geom_point() + 
  labs(xlab = "Cost of VW Golf", title = "Comparison of Car Costs")+
theme_light()
d1_VT_1 <- ggplotly(d1_VT)
d1_VT_1
#Cost of Apt vs Rent
d1_ARC = ggplot(d1, aes(x=AptRent, y = AptCostperSqM, color = City.Country)) +
  geom_point() +
  labs(title = "Comparison of Apartment - Rental vs Cost of Buying per Sq.M.")+
  geom_smooth(method = "lm", color = "blue") +
theme_light()
d1_ARC_1 <- ggplotly(d1_ARC)
d1_ARC_1
#Cost of Meals
d1_IE = ggplot(d1, aes(x=InexpensiveMeal, y = ExpensiveMeal, color = City.Country)) +
  geom_point() +
  labs(title = "Comparison of Meals")+
geom_smooth(method = "lm", color = "blue") +
  theme_light()
d1_IE_1 <- ggplotly(d1_IE)
d1_IE_1
plot(pressure)