I have provided you with data about the 5,000 fastest growing companies in the US, as compiled by Inc. magazine. Please use the data available at https://github.com/charleyferrari/CUNY_DATA608/tree/master/lecture1/Data

comp.data <- read.csv("https://raw.githubusercontent.com/charleyferrari/CUNY_DATA608/master/lecture1/Data/inc5000_data.csv")
comp.data <- as.data.frame(comp.data)
View(comp.data)

Once we have our data loaded, we will gather the data for how many companies there are in each state.

require(plyr)
## Loading required package: plyr
## Warning: package 'plyr' was built under R version 3.4.1
states.count <- count(comp.data, vars = "State")
states.count <- arrange(states.count, desc(freq))
states.count <- transform(states.count, State = reorder(State, freq)) #this ensures that our plot goes from greates to least

Now that we have our states in order by most companies to least, we can plot the frequency, keeping in mind that we are viewing on a portrait oriented screen.

require(ggplot2)
## Loading required package: ggplot2
## Warning: package 'ggplot2' was built under R version 3.4.1
ggplot(states.count, aes(x = State, y = freq)) +
  geom_bar(stat = "identity") + coord_flip() + ylab("Number of Companies") +   
  ggtitle("Fastest Growing Companies in the U.S. By State")

ggsave("Figure1.png")
## Saving 7 x 5 in image
#having the states as our Y axis and the frequency on the x bar, as well as using coord_flip() for our portrait screen.

Let’s dig in on the State with the 3rd most companies in the data set. Imagine you work for the state and are interested in how many people are employed by companies in different industries employ. Create a plot of average employment by industry for companies in this state (only use cases with full data (user R’s complete.cases() function). Your graph should show how variable the ranges are, and exclude outliers. + If we look at our plot from above, we can see that NY has the 3rd most companies in the data set. We will create a subset of just the companies in NY.

ny.data <- subset(comp.data, State == "NY")
ny.data
##      Rank                                         Name Growth_Rate
## 26     26                                 BeenVerified       84.43
## 30     30                                     Sailthru       73.22
## 37     37                                 YellowHammer       67.40
## 38     38                                    Conductor       67.02
## 48     48                    Cinium Financial Services       53.65
## 70     70                                     33Across       44.99
## 71     71                                   LiveIntent       44.85
## 124   124                             Quantum Networks       29.44
## 126   126                     Renegade Furniture Group       29.26
## 153   153                                  Regal Wings       25.13
## 174   174                                   Refinery29       23.01
## 218   219                           Novisync Solutions       19.28
## 231   232                               Rethink Autism       18.27
## 249   250                                Gravity Media       17.24
## 263   264                                    MSR Promo       16.30
## 266   267                                   NUE Agency       16.04
## 274   275                          Technical Solutions       15.85
## 279   280                                 RosettaBooks       15.49
## 284   285                                          SET       15.28
## 298   299                 Ultraflex Power Technologies       14.54
## 308   309                                     Ivy Exec       14.01
## 313   314                                      Panjiva       13.77
## 387   388                   Odyssey Telecommunications       11.40
## 399   400                               Forward Health       11.07
## 417   418                                         Grok       10.77
## 449   450                              Carrot Creative       10.24
## 464   465                                Bustin Boards        9.92
## 489   490                          MASS Communications        9.33
## 496   497                                  RCS Capital        9.19
## 501   502                                    Largetail        9.10
## 514   515                             Integra Networks        8.83
## 520   521                          Happy Family Brands        8.70
## 521   522                         Rockhedge Herb Farms        8.70
## 525   526                             Surface Magazine        8.63
## 567   568                                LocalResponse        7.94
## 608   609                             SmartWatt Energy        7.54
## 631   632                             Armadale Capital        7.27
## 655   656                           ForwardThink Group        7.01
## 659   660                                       OnDeck        6.98
## 660   661                         Quality In Real Time        6.94
## 668   669                                   Touchstorm        6.84
## 700   701                        Thrillist Media Group        6.52
## 708   709                                 Driven Local        6.45
## 713   714                              The Classy Home        6.43
## 716   717                            Merchant Industry        6.42
## 727   728                           Vector Media Group        6.30
## 743   744                                  BulbAmerica        6.16
## 749   750                                   Livestream        6.13
## 751   752                                 Private Prep        6.12
## 768   769                                Peeled Snacks        5.94
## 787   788                               Digital Energy        5.79
## 808   809                               The Ruby Group        5.57
## 814   815                                  Fingerpaint        5.55
## 817   818                          Salzinger & Company        5.53
## 829   830                        Launchpad Advertising        5.40
## 831   832                      In the Know Experiences        5.39
## 853   854                                    Hipercept        5.23
## 882   883                 Envisage Information Systems        5.04
## 889   890                                     Payoneer        5.00
## 895   896                                    Optimatic        4.97
## 921   922                              Rebecca Minkoff        4.75
## 934   935                                        Ioxus        4.67
## 970   971                       Imagine Easy Solutions        4.45
## 1009 1010                             Resolute Digital        4.26
## 1019 1020                                BarkerGilmore        4.22
## 1027 1028                     Direct Transport Systems        4.15
## 1035 1036                                       Enstoa        4.11
## 1047 1048                                 Curbed Media        4.06
## 1053 1054                                        Tarte        4.03
## 1066 1067                          Dionysus Consulting        3.96
## 1068 1069                          Systems Made Simple        3.94
## 1090 1091                          Blue Fountain Media        3.85
## 1094 1095                          UpSurge Media Group        3.84
## 1099 1100                                 ArkNet Media        3.82
## 1118 1119                                     Adafruit        3.75
## 1128 1129                               Likeable Media        3.72
## 1165 1166                     Manhattan Strategy Group        3.60
## 1180 1181                                     Sub Rosa        3.56
## 1189 1190                                    Usablenet        3.52
## 1202 1203                                     InRhythm        3.47
## 1209 1210                                     Trepoint        3.43
## 1213 1214                           ALAC International        3.42
## 1233 1234                                     Berricle        3.34
## 1258 1259                              Decorplanet.com        3.25
## 1292 1293                                Madison Logic        3.14
## 1370 1371                                     Impelsys        2.94
## 1381 1382                            City Sounds of NY        2.92
## 1422 1423                                Media6Degrees        2.82
## 1441 1442                        Global Warranty Group        2.78
## 1442 1443                              Oliver Staffing        2.78
## 1450 1451                    Professional Data Systems        2.76
## 1457 1458                            Dynomighty Design        2.74
## 1484 1485                        Cipher Tech Solutions        2.69
## 1498 1499                         Sterling Infosystems        2.66
## 1502 1503                           AdCorp Media Group        2.65
## 1539 1540                                   Gaffos.com        2.58
## 1558 1559                                     ModiFace        2.55
## 1564 1565                                       Droga5        2.54
## 1608 1609                              Enter:Marketing        2.47
## 1611 1612                             Andiamo Partners        2.46
## 1621 1622                              LJM Consultants        2.43
## 1639 1640                                     BlueWolf        2.38
## 1645 1646     New York Technology Partners - Rochester        2.37
## 1705 1706                                          MKG        2.27
## 1708 1709                                  Tribeca Nik        2.27
## 1716 1717                               Society Awards        2.26
## 1722 1723                                 Spicer Group        2.25
## 1754 1755                     Deep Blue Communications        2.19
## 1766 1767                               Vcorp Services        2.17
## 1875 1876                                  Servomation        2.03
## 1876 1877                                 MaeTec Power        2.03
## 1878 1879                              Durante Rentals        2.03
## 1894 1895                                nfrastructure        2.00
## 1919 1920               Reliance Star Payment Services        1.97
## 1953 1954                                  CleanEdison        1.94
## 1981 1982                             Imagine Swimming        1.89
## 1984 1985                      U.S. Energy Development        1.89
## 1985 1986                         Medical Supply Depot        1.89
## 2066 2067                      Signature Systems Group        1.81
## 2076 2077                                  Sachin Babi        1.80
## 2088 2089                                  React2Media        1.78
## 2115 2116           Charter School Business Management        1.76
## 2141 2142                       Liberty Jet Management        1.73
## 2172 2173                                PM Pediatrics        1.70
## 2178 2179                            Christmas Central        1.69
## 2197 2198                                    KJT Group        1.68
## 2208 2209                                        inVNT        1.67
## 2217 2218                                 Globo Mobile        1.67
## 2233 2234                                  WorkCompEDI        1.66
## 2279 2280                          Celerant Technology        1.60
## 2291 2292                         IntraLogic Solutions        1.59
## 2335 2336                                   BountyJobs        1.56
## 2351 2352                              LDJ Productions        1.54
## 2371 2372                     DiGennaro Communications        1.52
## 2398 2399                                         Rain        1.51
## 2404 2405                                     Sullivan        1.50
## 2431 2432                             Bear Metal Works        1.48
## 2435 2436                           Shinetech Software        1.48
## 2451 2452                                  Cafe Grumpy        1.46
## 2474 2475                  Systems Management/Planning        1.45
## 2493 2494                                          RVM        1.42
## 2502 2503                      Marvin Traub Associates        1.42
## 2505 2506                                       QueBIT        1.42
## 2525 2526                         Soleo Communications        1.40
## 2541 2542                             The Fortus Group        1.39
## 2548 2549                  Central Park West Dentistry        1.39
## 2555 2556                 Precision Pipeline Solutions        1.39
## 2560 2561                                   1st Equity        1.38
## 2561 2562               Advantage Communications Group        1.38
## 2584 2585                              Primary Support        1.36
## 2621 2622                                    Leviathan        1.34
## 2655 2656                                     TekScape        1.32
## 2665 2666                    Adventure in Food Trading        1.32
## 2674 2675                         Cedar Petrochemcials        1.31
## 2677 2678                               Treo Solutions        1.31
## 2701 2702                                Ryan Printing        1.30
## 2705 2706                           Primary Wave Media        1.30
## 2717 2718                                 CreativeFeed        1.29
## 2746 2747                             Stage 2 Networks        1.27
## 2750 2751                                      IOMedia        1.27
## 2763 2764                           Weiss & Associates        1.26
## 2783 2784                                 SportsSignup        1.25
## 2794 2795                                      Onco360        1.24
## 2798 2799                  School Choice International        1.24
## 2804 2805                      LeadDog Marketing Group        1.23
## 2827 2828                                           D4        1.22
## 2829 2830                                 ReSource Pro        1.22
## 2830 2831                              Taylor Creative        1.22
## 2876 2877                                Myriad Supply        1.19
## 2888 2889                            Logistic Dynamics        1.18
## 2895 2896                                         Telx        1.18
## 2923 2924                                 WTP Advisors        1.16
## 2963 2964                                      DataArt        1.14
## 2970 2971                                     ConServe        1.14
## 2980 2981                             Flexible Systems        1.13
## 2994 2995                           Pride Technologies        1.13
## 2996 2997                           Fibertech Networks        1.13
## 3008 3009                            5Linx Enterprises        1.12
## 3020 3021                                       Linium        1.11
## 3053 3054                                DDS Companies        1.09
## 3055 3056                                   VHMnetwork        1.09
## 3059 3060                                    Nasty Pig        1.09
## 3096 3097                             Gates Automotive        1.07
## 3102 3103                                SmartSign.com        1.07
## 3114 3115                               MyOTCStore.com        1.06
## 3116 3117                                Team Epiphany        1.06
## 3135 3136                       FSO Onsite Outsourcing        1.05
## 3145 3146                              Verge Marketing        1.04
## 3152 3153                       Juice Pharma Worldwide        1.04
## 3167 3168                              Atrium Staffing        1.03
## 3192 3193                         Access Display Group        1.02
## 3209 3210                                Dance With Me        1.01
## 3250 3251                             Modus Associates        0.99
## 3261 3262                               Sriven Systems        0.98
## 3288 3289                                  Butler/Till        0.97
## 3312 3313                            MyDailyMoment.com        0.96
## 3350 3351                            Bespoke Education        0.94
## 3354 3355                              Home Clean Home        0.94
## 3357 3358                                     HR Works        0.93
## 3382 3383                             Graduationsource        0.92
## 3386 3387                              Mitchell/Martin        0.92
## 3400 3401                      Alphaserve Technologies        0.92
## 3423 3424                          Stemp Systems Group       19.37
## 3500 3500                              Magnolia Bakery        0.88
## 3532 3532                              The Urban Group        0.86
## 3535 3535                                Tully Rinckey        0.86
## 3542 3542                                    SweetRiot        0.86
## 3544 3544                       Proactive Technologies        0.86
## 3549 3549                           Influence Graphics        0.86
## 3584 3584                                     Infusion        0.84
## 3592 3592                                Liberty Pumps        0.84
## 3594 3594                                    Post Beam        0.84
## 3601 3601                                Best Cleaners        0.84
## 3603 3603                              Gerstein Fisher        0.84
## 3632 3632                Integrated Systems Management        0.83
## 3643 3643                                    Docutrend        0.82
## 3661 3661 Environmental Products & Services of Vermont        0.81
## 3663 3663                            Liquid Technology        0.81
## 3685 3685                 Eminent Technology Solutions        0.80
## 3704 3704                Infinity Consulting Solutions        0.79
## 3716 3716                              LISS Consulting        0.79
## 3764 3764       American Portfolios Financial Services        0.77
## 3787 3787                              Optimax Systems        0.76
## 3789 3789                                 Xtreme Trips        0.76
## 3864 3864                                ClassBook.com        0.73
## 3871 3871                       eTransMedia Technology        0.72
## 3891 3891                                     Net@Work        0.72
## 3899 3899                    Denihan Hospitality Group        0.71
## 3924 3924              Finger Lakes Technologies Group        0.70
## 3925 3925                                         Sinu        0.70
## 3943 3943                                Gersh Academy        0.70
## 4000 4000                                Send Word Now        0.67
## 4003 4003                         Ovation Travel Group        0.67
## 4007 4007                       Spear Physical Therapy        0.67
## 4008 4008                                Nutricap Labs        0.67
## 4039 4039                                Empire Office        0.66
## 4054 4054                                         BUMI        0.65
## 4117 4117                                   NorthPoint        0.64
## 4128 4128                         Cvision Technologies        0.63
## 4153 4153                              Everyday Health        0.62
## 4154 4154           Business Communications Management        0.62
## 4158 4158                                     Edulence        0.62
## 4162 4162                                  JR Products        0.62
## 4166 4166                               Motivators.com        0.62
## 4170 4170               Creative Environment Solutions        0.62
## 4224 4224                                     Fragomen        0.60
## 4245 4245                Computer Resources of America        0.59
## 4250 4250                                     NiCoForm        0.59
## 4287 4287                                   LinguaLinx        0.57
## 4307 4307                                   ItsHot.com        0.57
## 4335 4335                           New York Kids Club        0.56
## 4336 4336                             Cyrus Innovation        0.56
## 4352 4352                                      Kitware        0.55
## 4363 4363                                 TransPerfect        0.55
## 4399 4399                                Direct Agents        0.54
## 4422 4422                            BPA International        0.53
## 4432 4432                                  C2C Outdoor        0.53
## 4447 4447                         Select Office Suites        0.52
## 4448 4448                           The Atlantic Group        0.52
## 4465 4465                                     OpenLink        0.52
## 4467 4467                               Blue Telescope        0.52
## 4471 4471                     KJ Technology Consulting        0.51
## 4474 4474                     Sam Schwartz Engineering        0.51
## 4475 4475                        Presentation Products        0.51
## 4490 4490                         Catseye Pest Control        0.51
## 4522 4522                             Geneva Worldwide        0.50
## 4535 4535                       Capital Access Network        0.49
## 4544 4544                 ePromos Promotional Products        0.49
## 4552 4552                                     Paradysz        0.49
## 4559 4559                                       Tabush        0.48
## 4560 4560             Sentry Communications & Security        0.48
## 4565 4565                                 EquipSystems        0.48
## 4569 4569                          Bogota Latin Bistro        0.48
## 4577 4577                   Sutherland Global Services        0.48
## 4595 4595                                      Numerix        0.48
## 4602 4602                              Brite Computers        0.47
## 4605 4605                                 QED National        0.47
## 4611 4611                                      Inergex        0.47
## 4632 4632                                  Transfinder        0.47
## 4639 4639  American Petroleum Equipment & Construction        0.46
## 4645 4645                                DatapointLabs        0.46
## 4646 4646                                    Mimeo.com        0.46
## 4652 4652                                   SaveAround        0.46
## 4670 4670                                      VarData        0.45
## 4671 4671                                    Webucator        0.45
## 4702 4702             Copier Fax Business Technologies        0.44
## 4716 4716                                Westcon Group        0.44
## 4727 4727                               Arrow Security        0.44
## 4728 4728                         DurAmerica Brokerage        0.43
## 4731 4731                                  PlayScripts        0.43
## 4732 4732                                      Mycroft        0.43
## 4738 4738                                  McMurry/TMG        0.43
## 4747 4747                                  TravelClick        0.43
## 4755 4755                              Greyston Bakery        0.42
## 4774 4774                              The Lloyd Group        0.42
## 4782 4782               Life Safety Engineered Systems        0.42
## 4800 4800                     Documentation Strategies        0.41
## 4803 4803                             Benefit Resource        0.41
## 4820 4820                                Aluf Plastics        0.40
## 4839 4839                                     Makovsky        0.40
## 4849 4849                         GTM Payroll Services        0.40
## 4853 4853                                       Affect        0.39
## 4891 4891                 Express Air Freight Unlmited        0.38
## 4896 4896              Rand Engineering & Architecture        0.38
## 4913 4913                                Jackson Lewis        0.37
## 4934 4934                               Buffalo Filter        0.37
## 4936 4936                                         Coty        0.36
## 4944 4944                              McElroy Deutsch        0.36
## 4950 4950             Colorspec Coatings International        0.36
## 4954 4954                          Premium Productions        0.36
## 4981 4981  SmartSource Computer & Audio Visual Rentals        0.35
##        Revenue                     Industry Employees             City
## 26   1.370e+07 Consumer Products & Services        17         New York
## 30   8.100e+06      Advertising & Marketing        79         New York
## 37   1.800e+07      Advertising & Marketing        27         New York
## 38   7.100e+06      Advertising & Marketing        89         New York
## 48   5.900e+06           Financial Services        32        Rock Hill
## 70   2.790e+07      Advertising & Marketing        75         New York
## 71   6.900e+06      Advertising & Marketing        42         New York
## 124  1.150e+07           Telecommunications        28         New York
## 126  9.800e+06                       Retail        17          Hewlett
## 153  1.540e+07         Travel & Hospitality        42         Brooklyn
## 174  1.660e+07                        Media        99         New York
## 218  7.500e+06                  IT Services       119         Fishkill
## 231  4.100e+06                    Education        22         New York
## 249  1.240e+07      Advertising & Marketing        15         New York
## 263  2.400e+06 Business Products & Services         4         New York
## 266  4.500e+06                        Media         4         New York
## 274  1.630e+07           Telecommunications       213           Walden
## 279  3.200e+06                        Media         7         New York
## 284  2.370e+07      Advertising & Marketing        46         New York
## 298  2.200e+06                Manufacturing        12       Ronkonkoma
## 308  2.200e+06              Human Resources        30         New York
## 313  4.000e+06 Business Products & Services        48         New York
## 387  3.300e+06           Telecommunications         6           colden
## 399  1.050e+07                       Health         6         New York
## 417  9.400e+06      Advertising & Marketing        19         New York
## 449  7.200e+06      Advertising & Marketing        45         Brooklyn
## 464  4.000e+06 Consumer Products & Services        25         Brooklyn
## 489  9.800e+06           Telecommunications        25         New York
## 496  2.875e+08           Financial Services       198         New York
## 501  3.700e+06      Advertising & Marketing        12         New York
## 514  1.660e+07           Telecommunications        31           Latham
## 520  6.250e+07 Consumer Products & Services        51         New York
## 521  5.100e+06              Food & Beverage        56  Pleasant Valley
## 525  3.900e+06                        Media        14         New York
## 567  3.900e+06      Advertising & Marketing        25         new york
## 608  3.880e+07                       Energy       137    Ballston Lake
## 631  3.600e+06                       Health         2         New York
## 655  2.170e+07           Financial Services        70         New York
## 659  3.670e+07           Financial Services       153         New York
## 660  2.900e+06                       Health       121      Floral Park
## 668  6.700e+06                        Media        46         New York
## 700  5.250e+07                        Media       200         New York
## 708  7.500e+06      Advertising & Marketing        28         Melville
## 713  2.800e+06 Consumer Products & Services        18         Brooklyn
## 716  2.240e+07           Financial Services       102 Long Island City
## 727  2.100e+06      Advertising & Marketing        12         New York
## 743  6.300e+06                       Retail        22         Brooklyn
## 749  1.890e+07                        Media       146         New York
## 751  2.500e+06                    Education       100         New York
## 768  5.800e+06              Food & Beverage        14         Brooklyn
## 787  1.230e+07 Consumer Products & Services        16         Brooklyn
## 808  1.100e+07                  Real Estate        15           Goshen
## 814  9.500e+06      Advertising & Marketing        51 Saratoga Springs
## 817  3.900e+06                  IT Services        15        Scarsdale
## 829  6.600e+06      Advertising & Marketing        40         New York
## 831  4.300e+06         Travel & Hospitality         6         New York
## 853  4.200e+06                  Real Estate        30         New York
## 882  1.700e+07                  IT Services       142           Ithaca
## 889  4.040e+07           Financial Services       207         New YOrk
## 895  8.700e+06      Advertising & Marketing         8         new york
## 921  5.890e+07                       Retail        75         New York
## 934  5.400e+06                       Energy        90          Oneonta
## 970  3.600e+06                    Education        19    New York City
## 1009 7.100e+06      Advertising & Marketing        28         New York
## 1019 2.100e+06              Human Resources        12         Fairport
## 1027 2.800e+06   Logistics & Transportation         1      Farmingdale
## 1035 7.000e+06                  IT Services        40         New York
## 1047 5.100e+06                        Media        45         New York
## 1053 5.240e+07 Consumer Products & Services       100         new york
## 1066 3.400e+06      Advertising & Marketing        22       West Islip
## 1068 1.671e+08                  IT Services       382         Syracuse
## 1090 1.420e+07      Advertising & Marketing       180         New York
## 1094 3.600e+06      Advertising & Marketing         2         New York
## 1099 5.300e+06 Consumer Products & Services        20      Garden City
## 1118 8.700e+06                Manufacturing        40         New York
## 1128 5.000e+06      Advertising & Marketing        65         New York
## 1165 6.300e+06 Business Products & Services        30         New York
## 1180 9.500e+06      Advertising & Marketing        28         New York
## 1189 5.900e+07                  IT Services       295         New York
## 1202 3.200e+06                  IT Services        27         New York
## 1209 4.300e+06      Advertising & Marketing        15       Great Neck
## 1213 5.650e+07                Manufacturing        11         New York
## 1233 2.200e+06                       Retail        11          ASTORIA
## 1258 1.380e+07                       Retail        61         New York
## 1292 1.490e+07      Advertising & Marketing        51         New York
## 1370 1.290e+07                     Software       220         New York
## 1381 2.000e+06                    Education        40         New York
## 1422 3.670e+07      Advertising & Marketing        87         New York
## 1441 2.810e+07                    Insurance        50         St James
## 1442 4.600e+06              Human Resources         7         New York
## 1450 6.300e+06                       Health        37     White Plains
## 1457 4.000e+06                       Retail        12         Brooklyn
## 1484 2.700e+06          Government Services        17            Nyack
## 1498 2.149e+08              Human Resources      2081         New York
## 1502 6.800e+06      Advertising & Marketing        38        IRVINGTON
## 1539 4.400e+06                       Retail        15           Inwood
## 1558 2.100e+06                     Software        25         New York
## 1564 6.730e+07      Advertising & Marketing       250         New York
## 1608 6.500e+06      Advertising & Marketing        35         New York
## 1611 6.200e+06              Human Resources         8         New York
## 1621 4.200e+06   Logistics & Transportation        22         Melville
## 1639 9.040e+07                  IT Services       500         New York
## 1645 3.200e+06                  IT Services        23        Rochester
## 1705 2.090e+07      Advertising & Marketing        41         New York
## 1708 4.700e+06 Consumer Products & Services         5      Lindenhurst
## 1716 3.300e+06 Consumer Products & Services        10 Long Island City
## 1722 5.600e+06                 Construction        20          Buffalo
## 1754 5.600e+06                  IT Services        47           Latham
## 1766 6.300e+06 Business Products & Services        15           Monsey
## 1875 5.500e+06              Food & Beverage        41        Canastota
## 1876 1.010e+07           Telecommunications        22         Fairport
## 1878 4.800e+06                 Construction        25            Bronx
## 1894 5.320e+07                  IT Services       237     Clifton Park
## 1919 2.000e+06           Financial Services        14  Oakland Gardens
## 1953 3.500e+06                    Education        25         New York
## 1981 5.100e+06                    Education       100         New York
## 1984 1.408e+08                       Energy       120        Getzville
## 1985 2.600e+06                       Retail         3         Brooklyn
## 2066 8.100e+07                Manufacturing        77         New York
## 2076 4.700e+06 Consumer Products & Services        23         New York
## 2088 5.600e+06      Advertising & Marketing        15         New York
## 2115 3.800e+06           Financial Services        33         New York
## 2141 8.900e+06         Travel & Hospitality        61       Ronkonkoma
## 2172 1.410e+07                       Health       181     Lake Success
## 2178 1.650e+07                       Retail        75      Cheektowaga
## 2197 7.200e+06 Business Products & Services        32    Honeoye Falls
## 2208 2.550e+07      Advertising & Marketing        44         New York
## 2217 4.500e+06                     Software       320         New York
## 2233 2.900e+06                  IT Services        13         Holbrook
## 2279 1.820e+07                     Software        80    Staten Island
## 2291 3.700e+06                     Security        25       Massapequa
## 2335 3.080e+07              Human Resources        56         New York
## 2351 1.230e+07 Business Products & Services        12         New York
## 2371 4.700e+06      Advertising & Marketing        32         New York
## 2398 1.070e+07      Advertising & Marketing        74         New York
## 2404 9.900e+06      Advertising & Marketing        63         New York
## 2431 2.400e+06                Manufacturing        13          Buffalo
## 2435 1.200e+07                  IT Services       300         New York
## 2451 2.200e+06              Food & Beverage        30         Brooklyn
## 2474 5.200e+07                  IT Services        52        Rochester
## 2493 1.880e+07 Business Products & Services       106         New York
## 2502 3.800e+06                       Retail        12         New York
## 2505 1.470e+07                  IT Services        46        Scarsdale
## 2525 1.410e+07           Telecommunications        85         Fairport
## 2541 6.200e+06                       Health        50            Utica
## 2548 3.100e+06                       Health        20         New York
## 2555 3.120e+07                       Energy       294      New Windsor
## 2560 2.100e+06                  Real Estate         7          Syosset
## 2561 5.600e+06           Telecommunications        15   Roslyn Heights
## 2584 2.300e+06                  IT Services        14         New York
## 2621 4.840e+07 Business Products & Services        11         Brooklyn
## 2655 1.360e+07                  IT Services        26         New York
## 2665 2.600e+06              Food & Beverage        12          Menands
## 2674 2.037e+08                       Energy         5         New York
## 2677 2.760e+07                       Health       166             troy
## 2701 7.300e+06                Manufacturing        26         blauvelt
## 2705 3.000e+06      Advertising & Marketing        15    Pleasantville
## 2717 9.700e+06      Advertising & Marketing        32         New York
## 2746 9.200e+06           Telecommunications        20         New York
## 2750 1.350e+07      Advertising & Marketing       133         New York
## 2763 2.000e+06 Consumer Products & Services         9         New York
## 2783 3.300e+06                     Software        21 Saratoga Springs
## 2794 1.122e+08                       Health        67         New York
## 2798 2.800e+06                    Education        21     White Plains
## 2804 3.290e+07      Advertising & Marketing       131         New York
## 2827 1.430e+07                  IT Services       125        Rochester
## 2829 2.430e+07 Business Products & Services      1124         New York
## 2830 9.200e+06      Advertising & Marketing        35         New York
## 2876 2.290e+07            Computer Hardware        44         New York
## 2888 3.960e+07   Logistics & Transportation        25          Amherst
## 2895 2.143e+08           Telecommunications       316         New York
## 2923 1.600e+07 Business Products & Services        90     White Plains
## 2963 3.070e+07                     Software       800         New York
## 2970 5.270e+07           Financial Services       483         Fairport
## 2980 2.960e+07                  IT Services        95        Hauppauge
## 2994 2.310e+08              Human Resources      1000         New York
## 2996 1.423e+08           Telecommunications       250        ROCHESTER
## 3008 1.036e+08           Telecommunications       268        Rochester
## 3020 4.590e+07                  IT Services       322         New York
## 3053 5.250e+07                 Construction       219        Rochester
## 3055 4.500e+06      Advertising & Marketing        10         New York
## 3059 2.000e+06                       Retail        10         New York
## 3096 6.900e+06 Consumer Products & Services        64        Henrietta
## 3102 2.530e+07 Business Products & Services        34         Brooklyn
## 3114 3.140e+07                       Retail        15         New York
## 3116 8.200e+06      Advertising & Marketing        37         New York
## 3135 5.530e+07              Human Resources      1134         New York
## 3145 4.000e+06      Advertising & Marketing        21         New York
## 3152 5.380e+07      Advertising & Marketing       186         New York
## 3167 9.700e+07              Human Resources       107         New York
## 3192 4.100e+06                Manufacturing        22         Freeport
## 3209 4.000e+06                    Education        50         New York
## 3250 2.300e+06      Advertising & Marketing         9         New York
## 3261 2.530e+07                  IT Services       210         Melville
## 3288 1.236e+08      Advertising & Marketing        73        Rochester
## 3312 5.900e+06                        Media        16         New York
## 3350 2.600e+06                    Education        70         New York
## 3354 2.100e+06 Consumer Products & Services        55         Brooklyn
## 3357 4.300e+06              Human Resources        53         Fairport
## 3382 5.300e+06                    Education        55     Port Chester
## 3386 1.453e+08                  IT Services      1000         New York
## 3400 1.640e+07                  IT Services        80         New York
## 3423 6.800e+06                  IT Services        39 Long Island City
## 3500 2.360e+07              Food & Beverage       383         New York
## 3532 5.700e+06                 Construction        24        Woodhaven
## 3535 8.800e+06 Consumer Products & Services        87           Albany
## 3542 2.000e+06              Food & Beverage         5         New York
## 3544 4.000e+06                  IT Services        24         New York
## 3549 4.100e+06      Advertising & Marketing        24         New York
## 3584 6.790e+07                  IT Services       432         New York
## 3592 6.080e+07                Manufacturing       132           Bergen
## 3594 5.900e+06      Advertising & Marketing        32         New York
## 3601 4.800e+06 Consumer Products & Services        85      Schenectady
## 3603 9.700e+06           Financial Services        35         New York
## 3632 4.600e+06                  IT Services       144        Tarrytown
## 3643 8.200e+06 Business Products & Services        45         New York
## 3661 4.510e+07       Environmental Services       250         Syracuse
## 3663 1.000e+07                  IT Services        33         Brooklyn
## 3685 6.300e+06                  IT Services        48          Buffalo
## 3704 3.570e+07              Human Resources       325         New York
## 3716 2.400e+06                  IT Services        18     Lake Success
## 3764 1.170e+08           Financial Services        81         Holbrook
## 3787 2.010e+07                Manufacturing       200          Ontario
## 3789 6.700e+06         Travel & Hospitality        30        plainview
## 3864 9.600e+06                    Education        61        Castleton
## 3871 2.590e+07                       Health       298             Troy
## 3891 2.930e+07                  IT Services       156         New York
## 3899 2.808e+08         Travel & Hospitality      2280         New York
## 3924 2.310e+07           Telecommunications       105           Victor
## 3925 3.000e+06                  IT Services        25         New York
## 3943 8.600e+06                    Education        51       Huntington
## 4000 1.660e+07           Telecommunications        59         New York
## 4003 5.860e+07         Travel & Hospitality       509         New York
## 4007 5.200e+06                       Health        40         New York
## 4008 3.000e+07                       Health        45      Farmingdale
## 4039 3.496e+08 Business Products & Services       345         New York
## 4054 2.300e+06                  IT Services         8         New York
## 4117 2.730e+07 Business Products & Services       144         New York
## 4128 5.200e+06                     Software        28     Forest Hills
## 4153 1.464e+08                        Media       602         New York
## 4154 1.090e+07           Telecommunications        21         New York
## 4158 2.000e+06                     Software        15         New York
## 4162 4.900e+06                Manufacturing        30  Clarence Center
## 4166 1.320e+07      Advertising & Marketing        55         westbury
## 4170 5.300e+06       Environmental Services        60         New York
## 4224 3.465e+08 Business Products & Services       404         New York
## 4245 7.700e+06                  IT Services        47         New York
## 4250 2.100e+06                Manufacturing        16        Rochester
## 4287 4.300e+06 Business Products & Services        32           Cohoes
## 4307 5.700e+06                       Retail         9         New York
## 4335 1.250e+07                    Education       200         New York
## 4336 5.900e+06                     Software        46         new york
## 4352 2.130e+07                     Software       110     Clifton Park
## 4363 3.413e+08 Business Products & Services      2218         New York
## 4399 2.270e+07      Advertising & Marketing        47         New York
## 4422 5.400e+06           Telecommunications       139      Carle Place
## 4432 2.770e+07      Advertising & Marketing        12         New York
## 4447 7.600e+06                  Real Estate        21         New York
## 4448 6.430e+07 Business Products & Services        51         New York
## 4465 3.043e+08                     Software      1271        Uniondale
## 4467 3.400e+06                        Media         9         New York
## 4471 4.000e+06                  IT Services        13         New York
## 4474 1.680e+07                  Engineering        94         New York
## 4475 9.700e+06                  Engineering        29         New York
## 4490 9.000e+06 Consumer Products & Services        62        Castleton
## 4522 7.400e+06 Business Products & Services        30         new york
## 4535 1.516e+08           Financial Services       425         New York
## 4544 2.840e+07      Advertising & Marketing       104         New York
## 4552 4.100e+07      Advertising & Marketing       270         New York
## 4559 3.900e+06                  IT Services        23         New York
## 4560 6.000e+06                     Security        40       Hicksville
## 4565 3.000e+06                       Health        31         New York
## 4569 3.800e+06              Food & Beverage        63         Brooklyn
## 4577 5.976e+08 Business Products & Services     32000        Pittsford
## 4595 5.640e+07                     Software       198         New York
## 4602 1.990e+07                  IT Services        54           Victor
## 4605 6.700e+06                  IT Services        89         New York
## 4611 1.740e+07                  IT Services       140          Buffalo
## 4632 7.800e+06                     Software        63      Schenectady
## 4639 1.040e+07                 Construction        68           Walden
## 4645 2.500e+06                  Engineering        11           Ithaca
## 4646 8.770e+07 Business Products & Services       632         New York
## 4652 6.900e+06      Advertising & Marketing        64       Binghamton
## 4670 1.480e+07           Telecommunications        18        Rochester
## 4671 4.600e+06                    Education        24       Jamesville
## 4702 5.300e+06 Business Products & Services        27          Buffalo
## 4716 3.800e+09                  IT Services      3000        Tarrytown
## 4727 1.400e+07                     Security       450         New York
## 4728 2.700e+06                    Insurance        15 Long Island City
## 4731 2.600e+06                       Retail        10         New York
## 4732 2.640e+07                  IT Services       275         New York
## 4738 9.140e+07      Advertising & Marketing       269    New York City
## 4747 2.571e+08         Travel & Hospitality       906         New York
## 4755 1.010e+07              Food & Beverage        84          Yonkers
## 4774 9.900e+06                  IT Services        73         New York
## 4782 7.100e+06                     Security        25          buffalo
## 4800 2.300e+06                  IT Services        25       Rensselaer
## 4803 1.330e+07 Business Products & Services        96        Rochester
## 4820 1.029e+08                Manufacturing       307       Orangeburg
## 4839 1.430e+07      Advertising & Marketing        55         New York
## 4849 6.700e+06           Financial Services        43     Clifton Park
## 4853 2.600e+06      Advertising & Marketing        18         New York
## 4891 2.860e+07   Logistics & Transportation        70          Jamaica
## 4896 9.800e+06                  Engineering        80         New York
## 4913 3.520e+08 Business Products & Services       690     White Plains
## 4934 1.500e+07                Manufacturing        67        Lancaster
## 4936 4.600e+09 Consumer Products & Services     10000         New York
## 4944 1.165e+08 Business Products & Services       288         New York
## 4950 3.300e+06                 Construction        10         Holbrook
## 4954 6.800e+06      Advertising & Marketing        16    Pleasantville
## 4981 5.730e+07 Business Products & Services       296        Hauppauge
##      State
## 26      NY
## 30      NY
## 37      NY
## 38      NY
## 48      NY
## 70      NY
## 71      NY
## 124     NY
## 126     NY
## 153     NY
## 174     NY
## 218     NY
## 231     NY
## 249     NY
## 263     NY
## 266     NY
## 274     NY
## 279     NY
## 284     NY
## 298     NY
## 308     NY
## 313     NY
## 387     NY
## 399     NY
## 417     NY
## 449     NY
## 464     NY
## 489     NY
## 496     NY
## 501     NY
## 514     NY
## 520     NY
## 521     NY
## 525     NY
## 567     NY
## 608     NY
## 631     NY
## 655     NY
## 659     NY
## 660     NY
## 668     NY
## 700     NY
## 708     NY
## 713     NY
## 716     NY
## 727     NY
## 743     NY
## 749     NY
## 751     NY
## 768     NY
## 787     NY
## 808     NY
## 814     NY
## 817     NY
## 829     NY
## 831     NY
## 853     NY
## 882     NY
## 889     NY
## 895     NY
## 921     NY
## 934     NY
## 970     NY
## 1009    NY
## 1019    NY
## 1027    NY
## 1035    NY
## 1047    NY
## 1053    NY
## 1066    NY
## 1068    NY
## 1090    NY
## 1094    NY
## 1099    NY
## 1118    NY
## 1128    NY
## 1165    NY
## 1180    NY
## 1189    NY
## 1202    NY
## 1209    NY
## 1213    NY
## 1233    NY
## 1258    NY
## 1292    NY
## 1370    NY
## 1381    NY
## 1422    NY
## 1441    NY
## 1442    NY
## 1450    NY
## 1457    NY
## 1484    NY
## 1498    NY
## 1502    NY
## 1539    NY
## 1558    NY
## 1564    NY
## 1608    NY
## 1611    NY
## 1621    NY
## 1639    NY
## 1645    NY
## 1705    NY
## 1708    NY
## 1716    NY
## 1722    NY
## 1754    NY
## 1766    NY
## 1875    NY
## 1876    NY
## 1878    NY
## 1894    NY
## 1919    NY
## 1953    NY
## 1981    NY
## 1984    NY
## 1985    NY
## 2066    NY
## 2076    NY
## 2088    NY
## 2115    NY
## 2141    NY
## 2172    NY
## 2178    NY
## 2197    NY
## 2208    NY
## 2217    NY
## 2233    NY
## 2279    NY
## 2291    NY
## 2335    NY
## 2351    NY
## 2371    NY
## 2398    NY
## 2404    NY
## 2431    NY
## 2435    NY
## 2451    NY
## 2474    NY
## 2493    NY
## 2502    NY
## 2505    NY
## 2525    NY
## 2541    NY
## 2548    NY
## 2555    NY
## 2560    NY
## 2561    NY
## 2584    NY
## 2621    NY
## 2655    NY
## 2665    NY
## 2674    NY
## 2677    NY
## 2701    NY
## 2705    NY
## 2717    NY
## 2746    NY
## 2750    NY
## 2763    NY
## 2783    NY
## 2794    NY
## 2798    NY
## 2804    NY
## 2827    NY
## 2829    NY
## 2830    NY
## 2876    NY
## 2888    NY
## 2895    NY
## 2923    NY
## 2963    NY
## 2970    NY
## 2980    NY
## 2994    NY
## 2996    NY
## 3008    NY
## 3020    NY
## 3053    NY
## 3055    NY
## 3059    NY
## 3096    NY
## 3102    NY
## 3114    NY
## 3116    NY
## 3135    NY
## 3145    NY
## 3152    NY
## 3167    NY
## 3192    NY
## 3209    NY
## 3250    NY
## 3261    NY
## 3288    NY
## 3312    NY
## 3350    NY
## 3354    NY
## 3357    NY
## 3382    NY
## 3386    NY
## 3400    NY
## 3423    NY
## 3500    NY
## 3532    NY
## 3535    NY
## 3542    NY
## 3544    NY
## 3549    NY
## 3584    NY
## 3592    NY
## 3594    NY
## 3601    NY
## 3603    NY
## 3632    NY
## 3643    NY
## 3661    NY
## 3663    NY
## 3685    NY
## 3704    NY
## 3716    NY
## 3764    NY
## 3787    NY
## 3789    NY
## 3864    NY
## 3871    NY
## 3891    NY
## 3899    NY
## 3924    NY
## 3925    NY
## 3943    NY
## 4000    NY
## 4003    NY
## 4007    NY
## 4008    NY
## 4039    NY
## 4054    NY
## 4117    NY
## 4128    NY
## 4153    NY
## 4154    NY
## 4158    NY
## 4162    NY
## 4166    NY
## 4170    NY
## 4224    NY
## 4245    NY
## 4250    NY
## 4287    NY
## 4307    NY
## 4335    NY
## 4336    NY
## 4352    NY
## 4363    NY
## 4399    NY
## 4422    NY
## 4432    NY
## 4447    NY
## 4448    NY
## 4465    NY
## 4467    NY
## 4471    NY
## 4474    NY
## 4475    NY
## 4490    NY
## 4522    NY
## 4535    NY
## 4544    NY
## 4552    NY
## 4559    NY
## 4560    NY
## 4565    NY
## 4569    NY
## 4577    NY
## 4595    NY
## 4602    NY
## 4605    NY
## 4611    NY
## 4632    NY
## 4639    NY
## 4645    NY
## 4646    NY
## 4652    NY
## 4670    NY
## 4671    NY
## 4702    NY
## 4716    NY
## 4727    NY
## 4728    NY
## 4731    NY
## 4732    NY
## 4738    NY
## 4747    NY
## 4755    NY
## 4774    NY
## 4782    NY
## 4800    NY
## 4803    NY
## 4820    NY
## 4839    NY
## 4849    NY
## 4853    NY
## 4891    NY
## 4896    NY
## 4913    NY
## 4934    NY
## 4936    NY
## 4944    NY
## 4950    NY
## 4954    NY
## 4981    NY
ny.plt <- boxplot(ny.data$Employees)

ny.plt
## $stats
##       [,1]
## [1,]   1.0
## [2,]  21.0
## [3,]  45.0
## [4,] 105.5
## [5,] 220.0
## attr(,"class")
##         1 
## "integer" 
## 
## $n
## [1] 311
## 
## $conf
##          [,1]
## [1,] 37.42934
## [2,] 52.57066
## 
## $out
##  [1]   382   295  2081   250   500   237   320   300   294  1124   316
## [12]   800   483  1000   250   268   322  1134  1000   383   432   250
## [23]   325   298  2280   509   345   602   404  2218  1271   425   270
## [34] 32000   632  3000   450   275   269   906   307   690 10000   288
## [45]   296
## 
## $group
##  [1] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
## [36] 1 1 1 1 1 1 1 1 1 1
## 
## $names
## [1] "1"
#now to find and replace out outliers

ny.plt$out
##  [1]   382   295  2081   250   500   237   320   300   294  1124   316
## [12]   800   483  1000   250   268   322  1134  1000   383   432   250
## [23]   325   298  2280   509   345   602   404  2218  1271   425   270
## [34] 32000   632  3000   450   275   269   906   307   690 10000   288
## [45]   296
ny <- rep(NA, length(ny.plt$out))

ny.employees <- ny.data$Employees

#http://www.dummies.com/programming/r/how-to-remove-rows-with-missing-data-in-r/

rep.outliers <- rep(NA, length(ny.plt$out))
ny.data$Employees <- mapvalues(ny.employees, ny.plt$out, rep.outliers, warn_missing = FALSE)

#now that we have replaced outliers with NA, we will go ahead a subset for just complete cases 

complete.ny <- ny.data[complete.cases(ny.data), ]
View(complete.ny)

Now that we have the data that we would like to work with, we will go ahead and plot. + I actually overlooked that it was asking to plot the averages so I will go ahead and find the average by industry first.

#https://www.rdocumentation.org/packages/plyr/versions/1.8.4/topics/ddply
emp.ave <- ddply(complete.ny, "Industry", function(x) mean(x$Employees))
colnames(emp.ave)[2] <- "AveEmployees"
View(emp.ave)

#to show how variable the ranges are, we will find the min and max and plot as well.

emp.min <- ddply(complete.ny, "Industry", function(x) min(x$Employees))
colnames(emp.min)[2] <- "MinEmployees"
View(emp.min)

emp.max <- ddply(complete.ny, "Industry", function(x) max(x$Employees))
colnames(emp.max)[2] <- "MaxEmployees"
View(emp.max)

Now to plot.

ggplot(emp.ave, aes(x = Industry, y = AveEmployees, color = "Average")) +
  geom_point() +
  geom_point(aes(y = emp.min$MinEmployees, color = "Minimum")) +
  geom_point(aes(y = emp.max$MaxEmployees, color = "Maximum")) +
  theme(legend.title = element_blank()) +
  ylab("Number of Employees") +
  ggtitle(paste("Employment by Industry for Companies in New York")) + coord_flip()

ggsave("Figure2.png")
## Saving 7 x 5 in image
#our plot shows the max, min and mean of each industry for the companies in NY

Now imagine you work for an investor and want to see which industries generate the most revenue per employee. Create a chart that makes this information clear.

comp <- comp.data[complete.cases(comp.data),]

rev.emp <- ddply(comp, "Industry", function(x) sum(x$Revenue)/sum(x$Employees))

colnames(rev.emp)[2] <- "RevenueEmployee"

ggplot(rev.emp, aes(x = Industry, y = RevenueEmployee)) +
  geom_bar(stat = "identity") + ylab("Revenue per Employee") + 
  ggtitle("Revenue per Employee by Industry") + coord_flip()

ggsave("Figure3.png")
## Saving 7 x 5 in image