Loading the data:

##   lga_id       unique_lga pop_2006       lga     state          zone
## 1      1     borno_abadam   100180    Abadam     Borno     Northeast
## 2      2        fct_abaji    58444     Abaji       FCT North-Central
## 3      3   akwa_ibom_abak   139090      Abak Akwa Ibom   South-South
## 4      4 ebonyi_abakaliki   151723 Abakaliki    Ebonyi     Southeast
## 5      5   abia_aba_north   107488 Aba North      Abia     Southeast
## 6      6   abia_aba_south   423852 Aba South      Abia     Southeast
##   area_sq_km surveying_effort pop_density_2006 longitude latitude
## 1    3967.05           Others            25.25    13.326   13.428
## 2     992.36              113            58.89     6.853    8.878
## 3     189.98           Others           732.11     7.772    5.020
## 4     584.06           Others           259.78     8.220    6.259
## 5      22.78           Others          4719.55     7.372    5.107
## 6      49.17           Others          8620.74     7.351    5.081
##   senatorial_district                       TA_names
## 1               North               Mukhtar Abubakar
## 2                                      Ipah Iloye A.
## 3         Ikot Ekpene                    Jesse Akpan
## 4        Ebonyi North             Obasi Arisi Ikenna
## 5          Abia South Anichukwueze Anthony Nkemdirim
## 6          Abia South          Ujah Chukwudu Francis
## 'data.frame':    50 obs. of  10 variables:
##  $ lga                   : Factor w/ 50 levels "Aliero","Anaocha",..: 6 2 7 38 17 4 16 26 8 18 ...
##  $ lga_id                : int  91 49 96 611 258 76 232 441 101 261 ...
##  $ state                 : Factor w/ 24 levels "Abia","Adamawa",..: 21 3 14 10 5 3 4 17 6 18 ...
##  $ zone                  : Factor w/ 6 levels "North-Central",..: 1 5 3 5 1 5 2 6 4 1 ...
##  $ c_section_yn          : logi  FALSE FALSE FALSE FALSE FALSE FALSE ...
##  $ num_nurses_fulltime   : int  0 2 1 0 0 0 0 1 3 0 ...
##  $ gps                   : Factor w/ 50 levels "10.50716994 7.39845258 633.4000244140625 5.0",..: 48 27 14 24 42 30 7 33 34 47 ...
##  $ num_lab_techs_fulltime: int  1 NA 1 0 0 1 0 0 2 0 ...
##  $ management            : Factor w/ 1 level "public": 1 1 1 1 1 1 1 NA 1 1 ...
##  $ num_doctors_fulltime  : int  0 NA 0 0 0 1 0 1 0 0 ...
##           lga lga_id   state          zone c_section_yn
## 1 Barkin-Ladi     91 Plateau North-Central        FALSE
## 2     Anaocha     49 Anambra     Southeast        FALSE
## 3     Batsari     96 Katsina     Northwest        FALSE
## 4        Orlu    611     Imo     Southeast        FALSE
## 5        Guma    258   Benue North-Central        FALSE
## 6    Ayamelum     76 Anambra     Southeast        FALSE
##   num_nurses_fulltime                                           gps
## 1                   0   9.57723376 8.98908176 1285.699951171875 5.0
## 2                   2   6.07903635 7.00366347 276.1000061035156 5.0
## 3                   1  12.91273864 7.31050997 472.3999938964844 5.0
## 4                   0 5.768364071846008 7.061988115310669 241.0 4.0
## 5                   0  7.71806025 8.74342196 147.89999389648438 5.0
## 6                   0  6.481826305389404 6.938955187797546 78.0 6.0
##   num_lab_techs_fulltime management num_doctors_fulltime
## 1                      1     public                    0
## 2                     NA     public                   NA
## 3                      1     public                    0
## 4                      0     public                    0
## 5                      0     public                    0
## 6                      1     public                    1
## [1] North-Central Southeast     Northwest     Northeast     Southwest    
## [6] South-South  
## 6 Levels: North-Central Northeast Northwest South-South ... Southwest

From the Nigeria Facilities Inventory data, select all facilities located in the Southern zones of Nigeria.

##                  lga lga_id       state        zone c_section_yn
## 2            Anaocha     49     Anambra   Southeast        FALSE
## 4               Orlu    611         Imo   Southeast        FALSE
## 6           Ayamelum     76     Anambra   Southeast        FALSE
## 8             Kosofe    441       Lagos   Southwest         TRUE
## 9            Bekwara    101 Cross River South-South        FALSE
## 11          Ise/Orun    359       Ekiti   Southwest        FALSE
## 15        Ezinihitte    218         Imo   Southeast         TRUE
## 16           Shagamu    671        Ogun   Southwest        FALSE
## 17            Ihiala    312     Anambra   Southeast         TRUE
## 19       Ndokwa-West    523       Delta South-South         TRUE
## 20          Surulere    694       Lagos   Southwest         TRUE
## 27          Ekwusigo    191     Anambra   Southeast         TRUE
## 28     Umuahia North    728        Abia   Southeast         TRUE
## 30             Ogoja    569 Cross River South-South        FALSE
## 31         Ika South    324       Delta South-South        FALSE
## 32       Ehime-Mbano    183         Imo   Southeast        FALSE
## 34            Mushin    516       Lagos   Southwest        FALSE
## 35          Odukpani    559 Cross River South-South        FALSE
## 40 Ogba/Egbema/Ndoni    562      Rivers South-South        FALSE
## 41       Warri South    746       Delta South-South        FALSE
## 43        Remo North    651        Ogun   Southwest         TRUE
## 44       Ijebu North    316        Ogun   Southwest        FALSE
## 46   Atakunmosa West     67        Osun   Southwest        FALSE
## 48        Uhunmwonde    722         Edo South-South        FALSE
## 49          Ifelodun    304        Osun   Southwest         TRUE
## 50     Ughelli South    720       Delta South-South        FALSE
##    num_nurses_fulltime                                            gps
## 2                    2    6.07903635 7.00366347 276.1000061035156 5.0
## 4                    0  5.768364071846008 7.061988115310669 241.0 4.0
## 6                    0   6.481826305389404 6.938955187797546 78.0 6.0
## 8                    1    6.60113991 3.41806628 35.29999923706055 5.0
## 9                    3 6.6513848304748535 8.869051337242126 151.0 4.0
## 11                   2    7.46085228 5.4184795 390.29998779296875 5.0
## 15                   7    5.49070932 7.28365219 165.3000030517578 5.0
## 16                   0     6.69276612 3.49483379 92.4000015258789 5.0
## 17                   2   5.88475837 6.89508114 110.30000305175781 5.0
## 19                   8   5.70480295 6.43165459 34.099998474121094 5.0
## 20                   3   6.49775137 3.35969109 42.400001525878906 5.0
## 27                   0                5.95802932 6.84972263 148.0 5.0
## 28                  NA     5.5224549 7.49361609 175.1999969482422 5.0
## 30                   0   6.477068066596985 8.580247163772583 66.0 4.0
## 31                   1  6.247004270553589 6.134732365608215 178.0 4.0
## 32                   1  5.662475824356079 7.232480049133301 164.0 4.0
## 34                   0                 6.52714249 3.34915425 43.5 5.0
## 35                   0   5.494038462638855 7.967378497123718 38.0 4.0
## 40                   2   5.36041084 6.67822917 30.399999618530273 5.0
## 41                   0    5.5714229 5.70460127 38.400001525878906 5.0
## 43                   0   6.98168426 3.68639208 123.19999694824219 5.0
## 44                   0   6.97047814 3.81543107 102.19999694824219 5.0
## 46                   0   7.52274164 4.62185659 407.20001220703125 5.0
## 48                   0  6.679955720901489 6.085991263389587 306.0 4.0
## 49                   6   7.91940107 4.65994516 421.70001220703125 5.0
## 50                   1   5.37297057 5.91941726 25.200000762939453 5.0
##    num_lab_techs_fulltime management num_doctors_fulltime
## 2                      NA     public                   NA
## 4                       0     public                    0
## 6                       1     public                    1
## 8                       0       <NA>                    1
## 9                       2     public                    0
## 11                      0       <NA>                    1
## 15                      1       <NA>                    0
## 16                      0     public                    0
## 17                      0       <NA>                    1
## 19                      1       <NA>                    2
## 20                      2       <NA>                    3
## 27                      0       <NA>                    1
## 28                     41     public                  308
## 30                      0     public                    0
## 31                      0     public                    0
## 32                      0       <NA>                    0
## 34                      0     public                    0
## 35                      0       <NA>                    0
## 40                      0       <NA>                    2
## 41                      0     public                    0
## 43                      1       <NA>                    2
## 44                      0     public                    0
## 46                      0     public                    0
## 48                      0     public                    0
## 49                      1       <NA>                    1
## 50                      0     public                    0
## [1] North-Central
## 6 Levels: North-Central Northeast Northwest South-South ... Southwest

Incorporate the pop2006 column from the lgas.csv file into the new data.frame containing only those facilities located in Southern Nigeria. We used lga_id in both datasets to complete the merge.

##    lga_id             lga.x     state.x      zone.x c_section_yn
## 1      49           Anaocha     Anambra   Southeast        FALSE
## 2      67   Atakunmosa West        Osun   Southwest        FALSE
## 3      76          Ayamelum     Anambra   Southeast        FALSE
## 4     101           Bekwara Cross River South-South        FALSE
## 5     183       Ehime-Mbano         Imo   Southeast        FALSE
## 6     191          Ekwusigo     Anambra   Southeast         TRUE
## 7     218        Ezinihitte         Imo   Southeast         TRUE
## 8     304          Ifelodun        Osun   Southwest         TRUE
## 9     312            Ihiala     Anambra   Southeast         TRUE
## 10    316       Ijebu North        Ogun   Southwest        FALSE
## 11    324         Ika South       Delta South-South        FALSE
## 12    359          Ise/Orun       Ekiti   Southwest        FALSE
## 13    441            Kosofe       Lagos   Southwest         TRUE
## 14    516            Mushin       Lagos   Southwest        FALSE
## 15    523       Ndokwa-West       Delta South-South         TRUE
## 16    559          Odukpani Cross River South-South        FALSE
## 17    562 Ogba/Egbema/Ndoni      Rivers South-South        FALSE
## 18    569             Ogoja Cross River South-South        FALSE
## 19    611              Orlu         Imo   Southeast        FALSE
## 20    651        Remo North        Ogun   Southwest         TRUE
## 21    671           Shagamu        Ogun   Southwest        FALSE
## 22    694          Surulere       Lagos   Southwest         TRUE
## 23    720     Ughelli South       Delta South-South        FALSE
## 24    722        Uhunmwonde         Edo South-South        FALSE
## 25    728     Umuahia North        Abia   Southeast         TRUE
## 26    746       Warri South       Delta South-South        FALSE
##    num_nurses_fulltime                                            gps
## 1                    2    6.07903635 7.00366347 276.1000061035156 5.0
## 2                    0   7.52274164 4.62185659 407.20001220703125 5.0
## 3                    0   6.481826305389404 6.938955187797546 78.0 6.0
## 4                    3 6.6513848304748535 8.869051337242126 151.0 4.0
## 5                    1  5.662475824356079 7.232480049133301 164.0 4.0
## 6                    0                5.95802932 6.84972263 148.0 5.0
## 7                    7    5.49070932 7.28365219 165.3000030517578 5.0
## 8                    6   7.91940107 4.65994516 421.70001220703125 5.0
## 9                    2   5.88475837 6.89508114 110.30000305175781 5.0
## 10                   0   6.97047814 3.81543107 102.19999694824219 5.0
## 11                   1  6.247004270553589 6.134732365608215 178.0 4.0
## 12                   2    7.46085228 5.4184795 390.29998779296875 5.0
## 13                   1    6.60113991 3.41806628 35.29999923706055 5.0
## 14                   0                 6.52714249 3.34915425 43.5 5.0
## 15                   8   5.70480295 6.43165459 34.099998474121094 5.0
## 16                   0   5.494038462638855 7.967378497123718 38.0 4.0
## 17                   2   5.36041084 6.67822917 30.399999618530273 5.0
## 18                   0   6.477068066596985 8.580247163772583 66.0 4.0
## 19                   0  5.768364071846008 7.061988115310669 241.0 4.0
## 20                   0   6.98168426 3.68639208 123.19999694824219 5.0
## 21                   0     6.69276612 3.49483379 92.4000015258789 5.0
## 22                   3   6.49775137 3.35969109 42.400001525878906 5.0
## 23                   1   5.37297057 5.91941726 25.200000762939453 5.0
## 24                   0  6.679955720901489 6.085991263389587 306.0 4.0
## 25                  NA     5.5224549 7.49361609 175.1999969482422 5.0
## 26                   0    5.5714229 5.70460127 38.400001525878906 5.0
##    num_lab_techs_fulltime management num_doctors_fulltime
## 1                      NA     public                   NA
## 2                       0     public                    0
## 3                       1     public                    1
## 4                       2     public                    0
## 5                       0       <NA>                    0
## 6                       0       <NA>                    1
## 7                       1       <NA>                    0
## 8                       1       <NA>                    1
## 9                       0       <NA>                    1
## 10                      0     public                    0
## 11                      0     public                    0
## 12                      0       <NA>                    1
## 13                      0       <NA>                    1
## 14                      0     public                    0
## 15                      1       <NA>                    2
## 16                      0       <NA>                    0
## 17                      0       <NA>                    2
## 18                      0     public                    0
## 19                      0     public                    0
## 20                      1       <NA>                    2
## 21                      0     public                    0
## 22                      2       <NA>                    3
## 23                      0     public                    0
## 24                      0     public                    0
## 25                     41     public                  308
## 26                      0     public                    0
##                  unique_lga pop_2006             lga.y     state.y
## 1           anambra_anaocha   285002           Anaocha     Anambra
## 2      osun_atakunmosa_west    68643   Atakunmosa West        Osun
## 3          anambra_ayamelum   158410          Ayamelum     Anambra
## 4       cross_river_bekwara   105822           Bekwara Cross River
## 5           imo_ehime_mbano   130931       Ehime-Mbano         Imo
## 6          anambra_ekwusigo   158231          Ekwusigo     Anambra
## 7            imo_ezinihitte   165593        Ezinihitte         Imo
## 8             osun_ifelodun    96748          Ifelodun        Osun
## 9            anambra_ihiala   302158            Ihiala     Anambra
## 10         ogun_ijebu_north   284336       Ijebu North        Ogun
## 11          delta_ika_south   162594         Ika South       Delta
## 12           ekiti_ise_orun   113754          Ise/Orun       Ekiti
## 13             lagos_kosofe   665393            Kosofe       Lagos
## 14             lagos_mushin   633009            Mushin       Lagos
## 15        delta_ndokwa_west   149325       Ndokwa-West       Delta
## 16     cross_river_odukpani   192444          Odukpani Cross River
## 17 rivers_ogba_egbema_ndoni   284010 Ogba/Egbema/Ndoni      Rivers
## 18        cross_river_ogoja   171901             Ogoja Cross River
## 19                 imo_orlu   142717              Orlu         Imo
## 20          ogun_remo_north    59911        Remo North        Ogun
## 21             ogun_shagamu   253412           Shagamu        Ogun
## 22           lagos_surulere   503975          Surulere       Lagos
## 23      delta_ughelli_south   213576     Ughelli South       Delta
## 24           edo_uhunmwonde   120813        Uhunmwonde         Edo
## 25       abia_umuahia_north   220660     Umuahia North        Abia
## 26        delta_warri_south   303417       Warri South       Delta
##         zone.y area_sq_km surveying_effort pop_density_2006 longitude
## 1    Southeast     104.38           Others          2730.39     7.017
## 2    Southwest     577.55           Others           118.85     4.667
## 3    Southeast     588.71              148           269.08     6.989
## 4  South-South     305.57           Others           346.31     8.910
## 5    Southeast     168.62           Others           776.46     7.290
## 6    Southeast     116.47           Others          1358.59     6.848
## 7    Southeast     109.33           Others          1514.61     7.327
## 8    Southwest     114.53           Others           844.73     4.636
## 9    Southeast     251.83           Others          1199.83     6.872
## 10   Southwest     968.00           Others           293.74     3.984
## 11 South-South     435.86           Others           373.04     6.200
## 12   Southwest     432.27           Others           263.15     5.402
## 13   Southwest      81.52           Others          8162.20     3.408
## 14   Southwest      17.50           Others         36161.91     3.351
## 15 South-South     816.44           Others           182.90     6.341
## 16 South-South    1354.44              113           142.08     8.147
## 17 South-South     969.76           Others           292.87     6.636
## 18 South-South     972.26           Others           176.81     8.721
## 19   Southeast     131.65           Others          1084.09     7.038
## 20   Southwest     199.59           Others           300.18     3.732
## 21   Southwest     614.74           Others           412.22     3.583
## 22   Southwest      23.03           Others         21881.16     3.351
## 23 South-South     786.27           Others           271.63     5.901
## 24 South-South    2034.49           Others            59.38     5.911
## 25   Southeast     244.60           Others           902.13     7.485
## 26 South-South     633.77           Others           478.75     5.610
##    latitude senatorial_district                      TA_names
## 1     6.090       Anambra North        Azubuike Arinze Achike
## 2     7.517           Osun East      Adeyefa Adedayo Adeyinka
## 3     6.559     Anambra Central Okpalaosimiri Azubuike Nnamdi
## 4     6.698   Cross-River North        Patrick  Theresa Ogeyi
## 5     5.679              Okigwe            Leonard C. Onyeiwu
## 6     5.991       Anambra South Okpalaosimiri Azubuike Nnamdi
## 7     5.475              Owerri          Nwabugwu E. Nkemjika
## 8     7.921        Osun Central      Ogunleye, Victor Oluseun
## 9     5.851       Anambra South Okpalaosimiri Azubuike Nnamdi
## 10    7.015           Ogun East         Hammed Abayomi Adeola
## 11    6.182         Delta North              Ayuya Tega David
## 12    7.441         Ekiti South    Olatunbosun Taiwo Franklin
## 13    6.593          Lagos East             Douglas Adebowale
## 14    6.531       Lagos Central    Danmole- Olalade  Adenekan
## 15    5.801         Delta North         Ogbolu Chidi McDonald
## 16    5.165   Cross-River South                    Akima Edet
## 17    5.399         Rivers West  Amakiri Fikiniseleka Collins
## 18    6.511   Cross-River North        Patrick  Theresa Ogeyi
## 19    5.804                Orlu        Olebara Chukwuemeka C.
## 20    7.006           Ogun East         Hammed Abayomi Adeola
## 21    6.782           Ogun East         Hammed Abayomi Adeola
## 22    6.492       Lagos Central    Danmole- Olalade  Adenekan
## 23    5.344       Delta Central                 Dennis Bennis
## 24    6.503           Edo South               Ekweozoh Ijeoma
## 25    5.595        Abia Central           Orji Stanley Alozie
## 26    5.629         Delta South                 Dennis Bennis

Calculate the total number of full time nurses and doctors for all health facilities in each state.

##  [1] Anambra     Osun        Cross River Imo         Ogun       
##  [6] Delta       Ekiti       Lagos       Rivers      Edo        
## [11] Abia       
## 37 Levels: Abia Adamawa Akwa Ibom Anambra Bauchi Bayelsa Benue ... Zamfara
##          State Total Doctors + Nurses
## 1      Anambra                      7
## 2         Osun                      7
## 3  Cross River                      3
## 4          Imo                      8
## 5         Ogun                      2
## 6        Delta                     12
## 7        Ekiti                      3
## 8        Lagos                      8
## 9       Rivers                      4
## 10         Edo                      0
## 11        Abia                    308

Sort the resulting dataset by state population, in descending order.

##  [1] Anambra     Osun        Cross River Imo         Ogun       
##  [6] Delta       Ekiti       Lagos       Rivers      Edo        
## [11] Abia       
## 37 Levels: Abia Adamawa Akwa Ibom Anambra Bauchi Bayelsa Benue ... Zamfara
##          State State Population
## 1      Anambra           903801
## 2         Osun           165391
## 3  Cross River           470167
## 4          Imo           439241
## 5         Ogun           597659
## 6        Delta           828912
## 7        Ekiti           113754
## 8        Lagos          1802377
## 9       Rivers           284010
## 10         Edo           120813
## 11        Abia           220660
##          State Total Doctors + Nurses State Population
## 8        Lagos                      8          1802377
## 2      Anambra                      7           903801
## 4        Delta                     12           828912
## 9         Ogun                      2           597659
## 3  Cross River                      3           470167
## 7          Imo                      8           439241
## 11      Rivers                      4           284010
## 1         Abia                    308           220660
## 10        Osun                      7           165391
## 5          Edo                      0           120813
## 6        Ekiti                      3           113754