forbes <- read.csv("Forbes2000.csv")
str(forbes)
## 'data.frame':    2000 obs. of  9 variables:
##  $ X          : int  1 2 3 4 5 6 7 8 9 10 ...
##  $ rank       : int  1 2 3 4 5 6 7 8 9 10 ...
##  $ name       : chr  "Citigroup" "General Electric" "American Intl Group" "ExxonMobil" ...
##  $ country    : chr  "United States" "United States" "United States" "United States" ...
##  $ category   : chr  "Banking" "Conglomerates" "Insurance" "Oil & gas operations" ...
##  $ sales      : num  94.7 134.2 76.7 222.9 232.6 ...
##  $ profits    : num  17.85 15.59 6.46 20.96 10.27 ...
##  $ assets     : num  1264 627 648 167 178 ...
##  $ marketvalue: num  255 329 195 277 174 ...
profit_by_category <- aggregate(profits ~ category, data = forbes, FUN = sum)
profit_by_category_desc <-profit_by_category[order(-profit_by_category$profits),]
profit_by_category_desc 
##                            category profits
## 2                           Banking  132.11
## 19             Oil & gas operations  117.50
## 9            Diversified financials   78.93
## 10            Drugs & biotechnology   65.15
## 11             Food drink & tobacco   49.29
## 8                 Consumer durables   41.91
## 20                        Retailing   41.88
## 16                        Insurance   37.73
## 6                     Conglomerates   31.45
## 15    Household & personal products   24.19
## 13 Health care equipment & services   23.46
## 27                        Utilities   23.26
## 17                        Materials   19.01
## 22              Software & services   17.60
## 7                      Construction   15.65
## 5                         Chemicals   13.03
## 18                            Media   12.85
## 23  Technology hardware & equipment   12.13
## 3      Business services & supplies   11.95
## 21                   Semiconductors   11.35
## 26                   Transportation   10.83
## 14     Hotels restaurants & leisure    9.57
## 12                     Food markets    8.22
## 1               Aerospace & defense    5.48
## 4                     Capital goods    5.06
## 25                Trading companies    0.70
## 24      Telecommunications services  -59.93
profit_by_country <- aggregate(profits ~ country, data = forbes, FUN = sum)
profit_by_country
##                         country profits
## 1                        Africa   -0.01
## 2                     Australia   18.08
## 3     Australia/ United Kingdom    2.35
## 4                       Austria    0.86
## 5                       Bahamas    0.20
## 6                       Belgium    3.54
## 7                       Bermuda    9.11
## 8                        Brazil    6.78
## 9                        Canada   23.30
## 10               Cayman Islands    0.74
## 11                        Chile    0.65
## 12                        China   15.54
## 13               Czech Republic    0.42
## 14                      Denmark    5.22
## 15                      Finland    7.05
## 16                       France    7.37
## 17       France/ United Kingdom   -2.83
## 18                      Germany   -2.48
## 19                       Greece    2.20
## 20              Hong Kong/China    7.33
## 21                      Hungary    0.55
## 22                        India    9.37
## 23                    Indonesia    2.69
## 24                      Ireland    3.88
## 25                      Islands    0.74
## 26                       Israel    0.79
## 27                        Italy    7.52
## 28                        Japan    7.07
## 29                       Jordan    0.23
## 30                   Kong/China    4.76
## 31                        Korea    0.12
## 32                      Liberia    0.28
## 33                   Luxembourg   -0.25
## 34                     Malaysia    3.41
## 35                       Mexico    3.41
## 36                  Netherlands   -1.09
## 37  Netherlands/ United Kingdom   10.64
## 38                  New Zealand    0.42
## 39                       Norway    5.05
## 40                     Pakistan    0.41
## 41       Panama/ United Kingdom    1.18
## 42                         Peru    0.11
## 43                  Philippines    0.22
## 44                       Poland    0.28
## 45                     Portugal    1.55
## 46                       Russia   14.87
## 47                    Singapore    3.58
## 48                 South Africa    6.33
## 49                  South Korea   15.60
## 50                        Spain   11.74
## 51                       Sweden    4.78
## 52                  Switzerland   13.75
## 53                       Taiwan    5.68
## 54                     Thailand    1.64
## 55                       Turkey    2.71
## 56               United Kingdom   21.72
## 57    United Kingdom/ Australia    1.64
## 58  United Kingdom/ Netherlands    0.14
## 59 United Kingdom/ South Africa   -0.10
## 60                United States  487.40
## 61                    Venezuela    0.12
sales_by_country <- aggregate(sales ~ country, data =  forbes, FUN = sum)
sales_by_country_desc <- sales_by_country[order(-sales_by_country$sales),]
sales_by_country_desc
##                         country   sales
## 60                United States 7553.75
## 28                        Japan 3220.24
## 56               United Kingdom 1430.98
## 18                      Germany 1350.79
## 16                       France 1266.43
## 36                  Netherlands  476.58
## 52                  Switzerland  423.53
## 27                        Italy  418.77
## 9                        Canada  360.06
## 49                  South Korea  358.62
## 50                        Spain  227.46
## 51                       Sweden  199.31
## 2                     Australia  194.05
## 37  Netherlands/ United Kingdom  184.20
## 7                       Bermuda  136.81
## 12                        China  127.49
## 15                      Finland  113.21
## 22                        India  104.44
## 53                       Taiwan   96.30
## 8                        Brazil   95.08
## 46                       Russia   92.07
## 6                       Belgium   91.03
## 39                       Norway   86.24
## 35                       Mexico   66.94
## 14                      Denmark   63.49
## 48                 South Africa   61.86
## 31                        Korea   60.02
## 47                    Singapore   58.96
## 55                       Turkey   56.56
## 20              Hong Kong/China   40.88
## 24                      Ireland   38.12
## 4                       Austria   33.14
## 19                       Greece   30.34
## 33                   Luxembourg   28.37
## 34                     Malaysia   27.46
## 45                     Portugal   27.19
## 3     Australia/ United Kingdom   23.19
## 30                   Kong/China   22.87
## 54                     Thailand   22.62
## 23                    Indonesia   17.15
## 26                       Israel   16.48
## 1                        Africa   13.64
## 57    United Kingdom/ Australia   10.01
## 10               Cayman Islands    8.30
## 58  United Kingdom/ Netherlands    7.54
## 21                      Hungary    6.74
## 25                      Islands    6.67
## 11                        Chile    6.41
## 41       Panama/ United Kingdom    5.93
## 44                       Poland    4.41
## 32                      Liberia    3.78
## 13               Czech Republic    3.61
## 43                  Philippines    3.13
## 38                  New Zealand    2.64
## 59 United Kingdom/ South Africa    2.06
## 5                       Bahamas    1.35
## 29                       Jordan    1.33
## 40                     Pakistan    1.23
## 17       France/ United Kingdom    1.01
## 61                    Venezuela    0.98
## 42                         Peru    0.17

Which company types generate the highest (and lowest) profits? Banking

Which countries generate the most profits? The United States

What about sales? The United States


``` r
usa_japan <- subset(forbes, country %in% c("USA", "Japan"))

usa_japan_rank <- aggregate(rank ~ country, data = forbes, FUN = min)
usa_japan_rank
##                         country rank
## 1                        Africa  950
## 2                     Australia   86
## 3     Australia/ United Kingdom  122
## 4                       Austria  363
## 5                       Bahamas 1754
## 6                       Belgium   99
## 7                       Bermuda   76
## 8                        Brazil  127
## 9                        Canada   79
## 10               Cayman Islands 1101
## 11                        Chile  951
## 12                        China   55
## 13               Czech Republic 1125
## 14                      Denmark  133
## 15                      Finland   83
## 16                       France   17
## 17       France/ United Kingdom 1497
## 18                      Germany   21
## 19                       Greece  578
## 20              Hong Kong/China  144
## 21                      Hungary  994
## 22                        India  243
## 23                    Indonesia  688
## 24                      Ireland  221
## 25                      Islands  668
## 26                       Israel  792
## 27                        Italy   37
## 28                        Japan    8
## 29                       Jordan  962
## 30                   Kong/China  112
## 31                        Korea  998
## 32                      Liberia  675
## 33                   Luxembourg  595
## 34                     Malaysia  515
## 35                       Mexico  375
## 36                  Netherlands   12
## 37  Netherlands/ United Kingdom   13
## 38                  New Zealand  896
## 39                       Norway  117
## 40                     Pakistan 1410
## 41       Panama/ United Kingdom  259
## 42                         Peru 1944
## 43                  Philippines 1674
## 44                       Poland 1073
## 45                     Portugal  442
## 46                       Russia   87
## 47                    Singapore  318
## 48                 South Africa  359
## 49                  South Korea   45
## 50                        Spain   39
## 51                       Sweden  136
## 52                  Switzerland   11
## 53                       Taiwan  312
## 54                     Thailand  461
## 55                       Turkey  566
## 56               United Kingdom    5
## 57    United Kingdom/ Australia  188
## 58  United Kingdom/ Netherlands  840
## 59 United Kingdom/ South Africa 1489
## 60                United States    1
## 61                    Venezuela 1861
usa_cat <- subset(forbes, country == "United States")
category_type_usa <- table(usa_cat$category)
category_type_usa_desc <- sort(category_type_usa, decreasing = TRUE)
category_type_usa_desc
## 
##                          Banking           Diversified financials 
##                               83                               60 
##                        Utilities Health care equipment & services 
##                               54                               53 
##                        Retailing                        Insurance 
##                               53                               46 
##  Technology hardware & equipment             Oil & gas operations 
##                               33                               32 
##     Business services & supplies             Food drink & tobacco 
##                               31                               28 
##                            Media                        Materials 
##                               28                               26 
##                Consumer durables            Drugs & biotechnology 
##                               25                               21 
##              Software & services    Household & personal products 
##                               21                               20 
##                     Construction     Hotels restaurants & leisure 
##                               18                               17 
##                   Transportation                   Semiconductors 
##                               17                               16 
##      Telecommunications services                        Chemicals 
##                               16                               13 
##                    Conglomerates              Aerospace & defense 
##                               11                               10 
##                    Capital goods                     Food markets 
##                               10                                9
japan_cat <- subset(forbes, country == "Japan")
category_type_japan <- table(japan_cat$category)
cat_type_japan_desc <- sort(category_type_japan, decreasing = TRUE)
cat_type_japan_desc
## 
##                          Banking           Diversified financials 
##                               69                               24 
##                Consumer durables                   Transportation 
##                               22                               20 
##                    Capital goods                     Construction 
##                               19                               18 
##     Business services & supplies                        Chemicals 
##                               17                               14 
##                Trading companies                        Materials 
##                               13                               12 
##                        Retailing                        Utilities 
##                               12                               11 
##             Food drink & tobacco            Drugs & biotechnology 
##                               10                                9 
##                        Insurance    Household & personal products 
##                                9                                7 
##                            Media  Technology hardware & equipment 
##                                7                                6 
## Health care equipment & services             Oil & gas operations 
##                                4                                3 
##                   Semiconductors              Software & services 
##                                3                                3 
##                     Food markets      Telecommunications services 
##                                2                                2

Which country has the highest rank using Forbes ranking? United states

Which company types are more common in the USA? Banking

In Japan? Banking



``` r
lr_model <- forbes[, c("profits", "assets", "marketvalue", "sales")]
summary(lr_model)
##     profits             assets          marketvalue         sales        
##  Min.   :-25.8300   Min.   :   0.270   Min.   :  0.02   Min.   :  0.010  
##  1st Qu.:  0.0800   1st Qu.:   4.025   1st Qu.:  2.72   1st Qu.:  2.018  
##  Median :  0.2000   Median :   9.345   Median :  5.15   Median :  4.365  
##  Mean   :  0.3811   Mean   :  34.042   Mean   : 11.88   Mean   :  9.697  
##  3rd Qu.:  0.4400   3rd Qu.:  22.793   3rd Qu.: 10.60   3rd Qu.:  9.547  
##  Max.   : 20.9600   Max.   :1264.030   Max.   :328.54   Max.   :256.330  
##  NA's   :5
lm_model <- lm(profits ~ assets + marketvalue + sales, data = forbes)
anova(lm_model)
## Analysis of Variance Table
## 
## Response: profits
##               Df Sum Sq Mean Sq F value    Pr(>F)    
## assets         1  312.8  312.84  144.40 < 2.2e-16 ***
## marketvalue    1 1552.8 1552.77  716.71 < 2.2e-16 ***
## sales          1   35.8   35.79   16.52 5.001e-05 ***
## Residuals   1991 4313.6    2.17                      
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
usa_lm <- lm(profits ~ assets + marketvalue + sales, data = subset(forbes, country == "United States"))
anova(usa_lm)
## Analysis of Variance Table
## 
## Response: profits
##              Df Sum Sq Mean Sq  F value    Pr(>F)    
## assets        1 975.23  975.23 1479.783 < 2.2e-16 ***
## marketvalue   1 895.96  895.96 1359.498 < 2.2e-16 ***
## sales         1  30.41   30.41   46.142 2.253e-11 ***
## Residuals   744 490.32    0.66                       
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
japan_lm <- lm(profits ~ assets + marketvalue + sales, data = subset(forbes, country == "Japan"))
anova(japan_lm)
## Analysis of Variance Table
## 
## Response: profits
##              Df  Sum Sq Mean Sq F value Pr(>F)    
## assets        1 284.846 284.846 433.311 <2e-16 ***
## marketvalue   1 162.574 162.574 247.310 <2e-16 ***
## sales         1   0.024   0.024   0.036 0.8497    
## Residuals   312 205.100   0.657                   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

which variables are the most important for each region? assets

What differences do you observe? the US has far greater sales