Required packages

library(readxl)
library(knitr) 
library(stringr)
library(dplyr)
library(tidyr)
library(magrittr)
library(kableExtra)
library(ggplot2)

Executive Summary

This study involves 3 datasets merged together for analysis purpose.

  1. UN_MigrantStockByOriginAndDestination_2019 (Table 2-Male migrants). [1]
  2. UN_MigrantStockByOriginAndDestination_2019 (Table 3-Female migrants). [1]
  3. continents-according-to-our-world-in-data. [2]

Steps performed before importing the datasets in R.

The final Male and Female datasets contains 1982 rows and 241 columns each.

For the Continent dataset, there are 286 rows and 4 columns. Entire file is imported in R and then the columns containing Countries and Continents information are retained.

Data

The “UN_MigrantStockByOriginAndDestination_2019.xlsx” dataset present in the UN- Department of Economic and social affairs website, shows an approximated number of international migrants by origin, sex and age. Data are presented for years 1990, 1995, 2000, 2005, 2010, 2015 and 2019 and includes all countries/areas of the world. The data is divided into 3 tables, out of which we will use Table 2 (Stats of Male migrants) and Table 3 (Stats of Female migrants) for this study.

The data contains the following attributes:

Another dataset “continents-according-to-our-world-in-data.csv” present in the Our world in data website, is joined to create buckets of the countries with respect to the Continents they are located in.

Male_migrant<- read_excel("Male Migrants.xlsx")
Male_migrant$Gender <- "Male"

#[3]
head(Male_migrant) %>% kable(booktabs= T) %>% kable_styling(latex_options = c("striped", "scale_down"))%>% scroll_box(width="100%",height="350px")

Year Sort order Major area,region,country or area of destinations Notes Code Type of data(a) Total Other South Other North Afghanistan Albania Algeria American Samoa Andorra Angola Anguilla Antigua and Barbuda Argentina Armenia Aruba Australia Austria Azerbaijan Bahamas Bahrain Bangladesh Barbados Belarus Belgium Belize Benin Bermuda Bhutan Bolivia (Plurinational State of) Bonaire, Sint Eustatius and Saba Bosnia and Herzegovina Botswana Brazil British Virgin Islands Brunei Darussalam Bulgaria Burkina Faso Burundi Cabo Verde Cambodia Cameroon Canada Cayman Islands Central African Republic Chad Channel Islands Chile China China, Hong Kong SAR China, Macao SAR Colombia Comoros Congo Cook Islands Costa Rica Côte d'Ivoire Croatia Cuba Curaçao Cyprus Czechia Dem. People's Republic of Korea Democratic Republic of the Congo Denmark Djibouti Dominica Dominican Republic Ecuador Egypt El Salvador Equatorial Guinea Eritrea Estonia Eswatini Ethiopia Falkland Islands (Malvinas) Faroe Islands Fiji Finland France French Guiana French Polynesia Gabon Gambia Georgia Germany Ghana Gibraltar Greece Greenland Grenada Guadeloupe Guam Guatemala Guinea Guinea-Bissau Guyana Haiti Holy See Honduras Hungary Iceland India Indonesia Iran (Islamic Republic of) Iraq Ireland Isle of Man Israel Italy Jamaica Japan Jordan Kazakhstan Kenya Kiribati Kuwait Kyrgyzstan Lao People's Democratic Republic Latvia Lebanon Lesotho Liberia Libya Liechtenstein Lithuania Luxembourg Madagascar Malawi Malaysia Maldives Mali Malta Marshall Islands Martinique Mauritania Mauritius Mayotte Mexico Micronesia (Fed. States of) Monaco Mongolia Montenegro Montserrat Morocco Mozambique Myanmar Namibia Nauru Nepal Netherlands New Caledonia New Zealand Nicaragua Niger Nigeria Niue North Macedonia Northern Mariana Islands Norway Oman Pakistan Palau Panama Papua New Guinea Paraguay Peru Philippines Poland Portugal Puerto Rico Qatar Republic of Korea Republic of Moldova Réunion Romania Russian Federation Rwanda Saint Helena Saint Kitts and Nevis Saint Lucia Saint Pierre and Miquelon Saint Vincent and the Grenadines Samoa San Marino Sao Tome and Principe Saudi Arabia Senegal Serbia Seychelles Sierra Leone Singapore Sint Maarten (Dutch part) Slovakia Slovenia Solomon Islands Somalia South Africa South Sudan Spain Sri Lanka State of Palestine Sudan Suriname Sweden Switzerland Syrian Arab Republic Tajikistan Thailand Timor-Leste Togo Tokelau Tonga Trinidad and Tobago Tunisia Turkey Turkmenistan Turks and Caicos Islands Tuvalu Uganda Ukraine United Arab Emirates United Kingdom United Republic of Tanzania United States of America United States Virgin Islands Uruguay Uzbekistan Vanuatu Venezuela (Bolivarian Republic of) Viet Nam Wallis and Futuna Islands Western Sahara Yemen Zambia Zimbabwe Gender
1990 1990001 WORLD NA 900 NA 77661689 3412163 1159981 3711922 109462 521333 1049 1769 405495 1069 9817 203585 436870 4742 140739 234736 767943 10628 6120 3162922 40155 815549 157201 15094 127252 34703 13925 115446 1627 427370 19235 226370 1340 15605 300437 573295 173900 42683 174750 60068 367069 192 24207 168103 8755 248431 2197578 272012 48482 458889 22062 51516 8377 29259 185637 214262 399247 21911 90736 130307 19237 217217 91640 2890 19308 198693 105646 822942 608584 17710 89618 54319 25590 856303 141 2989 43627 101915 572512 1251 1595 7736 20808 446509 1341083 187378 5671 533599 3774 19604 2590 694 175902 201530 27432 110794 295179 13 66907 192180 8627 3808569 952658 362238 854950 413220 5098 139359 1739405 268189 301529 187416 1427482 123049 1937 45235 252638 237318 99944 292677 145916 260645 40088 1447 152604 18562 25594 84442 276687 1698 360545 56497 707 5609 75174 51465 986 2358113 3935 2256 11762 38819 3366 984687 1202056 376109 9361 627 389294 357079 1928 196197 219810 94787 255399 2832 217104 1204 59894 6450 1971601 1369 66563 1573 131629 150342 833735 706964 965010 574860 6028 808147 290611 1571 377349 5516075 276832 386 9534 10053 240 17907 36602 572 6742 57765 230827 393867 17221 31968 74563 7556 65930 39984 1134 448855 150244 266794 683813 459025 888310 336129 87554 87854 145574 355555 264426 122822 5921 95240 836 16197 87603 281462 1362030 127446 1006 1203 157870 2634767 44699 1876268 107187 869586 1175 116499 685800 2646 83012 636418 3664 92655 290313 42599 105757 Male
1990 1990002 UN development groups NA NA NA .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. Male
1990 1990003 More developed regions b 901 NA 40426798 1809849 507312 69707 108188 494762 505 1735 80403 280 6595 101201 321103 2020 109322 218340 516211 9741 1005 93241 37394 724917 143609 13289 8519 34623 353 21162 1465 423323 1516 114297 84 3341 63086 3635 2398 36722 114773 24650 336941 141 4634 2131 8720 89567 722302 254737 6926 157368 9295 33711 8358 19481 24371 212337 368086 19805 85825 126337 7690 50315 87959 1832 11381 166342 81237 159680 257214 4069 12907 52689 267 58633 130 2989 41697 100465 394850 29 137 4262 8577 392298 1123196 73769 5633 470860 3587 10793 81 22 123986 8558 9544 97936 145320 5 48351 179630 8584 635626 150834 302178 85827 409302 5098 88873 1448019 262462 204669 48955 1368478 78800 444 8502 234508 126654 93400 208539 179 10070 14153 1335 138545 18435 18026 6004 92098 163 33381 56397 547 158 9331 46175 0 2337466 1352 2135 11675 38702 2413 896077 37792 21839 633 217 4503 326551 536 187589 85610 2080 89477 2812 191059 136 55383 416 260857 6 44012 934 5946 101746 507133 631908 751116 565279 477 678290 263476 64 308201 3278092 4492 283 4522 4593 211 9419 28658 536 2760 12206 94339 392273 13807 11074 42019 7053 65626 39016 530 35133 107091 0 425753 148767 18878 9471 77368 82846 125358 76064 229232 70955 5436 11271 755 14745 80657 257235 1311909 122635 107 550 36354 2241388 3215 1713505 31252 436579 39 26639 521303 461 48599 557518 743 265 7284 12964 19649 Male
1990 1990004 Less developed regions c 902 NA 37234891 1602314 652669 3642215 1274 26571 544 34 325092 789 3222 102384 115767 2722 31417 16396 251732 887 5115 3069681 2761 90632 13592 1805 118733 80 13572 94284 162 4047 17719 112073 1256 12264 237351 569660 171502 5961 59977 35418 30128 51 19573 165972 35 158864 1475276 17275 41556 301521 12767 17805 19 9778 161266 1925 31161 2106 4911 3970 11547 166902 3681 1058 7927 32351 24409 663262 351370 13641 76711 1630 25323 797670 11 0 1930 1450 177662 1222 1458 3474 12231 54211 217887 113609 38 62739 187 8811 2509 672 51916 192972 17888 12858 149859 8 18556 12550 43 3172943 801824 60060 769123 3918 0 50486 291386 5727 96860 138461 59004 44249 1493 36733 18130 110664 6544 84138 145737 250575 25935 112 14059 127 7568 78438 184589 1535 327164 100 160 5451 65843 5290 986 20647 2583 121 87 117 953 88610 1164264 354270 8728 410 384791 30528 1392 8608 134200 92707 165922 20 26045 1068 4511 6034 1710744 1363 22551 639 125683 48596 326602 75056 213894 9581 5551 129857 27135 1507 69148 2237983 272340 103 5012 5460 29 8488 7944 36 3982 45559 136488 1594 3414 20894 32544 503 304 968 604 413722 43153 266794 258060 310258 869432 326658 10186 5008 20216 279491 35194 51867 485 83969 81 1452 6946 24227 50121 4811 899 653 121516 393379 41484 162763 75935 433007 1136 89860 164497 2185 34413 78900 2921 92390 283029 29635 86108 Male
1990 1990005 Least developed countries d 941 NA 5550233 244501 135262 0 0 2501 0 0 296132 0 0 296 0 0 809 155 0 0 49 1287 0 0 503 0 21560 0 8065 0 0 0 278 843 0 0 0 23068 169652 5780 7676 17913 976 0 13807 104323 0 214 129813 31 0 421 4777 12856 0 106 156487 0 858 0 3 0 60 127832 106 475 0 1345 0 16095 0 152 69934 0 58 714494 0 0 376 0 20115 0 0 2815 6676 0 2564 25683 0 21 0 0 0 0 0 118144 16933 0 0 0 0 1 0 158283 40346 0 2776 0 0 0 1696 0 5324 0 0 37703 483 9 0 31777 0 4398 1473 239503 1954 0 0 0 5007 27145 50228 0 66751 0 0 0 55824 70 0 131 0 0 0 0 0 1778 621480 106389 1683 400 5453 296 128 271 0 31791 57513 0 0 0 2299 0 10535 0 0 592 0 208 476 0 5151 703 0 171 0 507 0 772 268902 0 0 0 0 0 18 0 1659 1038 104819 0 3300 19179 5773 0 0 8 39 400790 10672 257061 1069 68 1482 124612 0 628 400 1313 22879 16699 0 12256 0 14 0 92 1 0 0 203 75525 39 24 8556 38482 20539 0 112 1144 3 1325 36996 0 0 175 10694 37287 Male
1990 1990006 Less developed regions, excluding least developed countries NA 934 NA 31684658 1357813 517407 3642215 1274 24070 544 34 28960 789 3222 102088 115767 2722 30608 16241 251732 887 5066 3068394 2761 90632 13089 1805 97173 80 5507 94284 162 4047 17441 111230 1256 12264 237351 546592 1850 181 52301 17505 29152 51 5766 61649 35 158650 1345463 17244 41556 301100 7990 4949 19 9672 4779 1925 30303 2106 4908 3970 11487 39070 3575 583 7927 31006 24409 647167 351370 13489 6777 1630 25265 83176 11 0 1554 1450 157547 1222 1458 659 5555 54211 215323 87926 38 62718 187 8811 2509 672 51916 74828 955 12858 149859 8 18556 12549 43 3014660 761478 60060 766347 3918 0 50486 289690 5727 91536 138461 59004 6546 1010 36724 18130 78887 6544 79740 144264 11072 23981 112 14059 127 2561 51293 134361 1535 260413 100 160 5451 10019 5220 986 20516 2583 121 87 117 953 86832 542784 247881 7045 10 379338 30232 1264 8337 134200 60916 108409 20 26045 1068 2212 6034 1700209 1363 22551 47 125683 48388 326126 75056 208743 8878 5551 129686 27135 1000 69148 2237211 3438 103 5012 5460 29 8488 7926 36 2323 44521 31669 1594 114 1715 26771 503 304 960 565 12932 32481 9733 256991 310190 867950 202046 10186 4380 19816 278178 12315 35168 485 71713 81 1438 6946 24135 50120 4811 899 450 45991 393340 41460 154207 37453 412468 1136 89748 163353 2182 33088 41904 2921 92390 282854 18941 48821 Male



Female_migrant<- read_excel("Female Migrants.xlsx")
Female_migrant$Gender <- "Female"
head(Female_migrant) %>% kable(booktabs= T) %>% kable_styling(latex_options = c("striped", "scale_down"))%>% scroll_box(width="100%",height="350px")

Year Sort order Major area,region,country or area of destinations Notes Code Type of data(a) Total Other South Other North Afghanistan Albania Algeria American Samoa Andorra Angola Anguilla Antigua and Barbuda Argentina Armenia Aruba Australia Austria Azerbaijan Bahamas Bahrain Bangladesh Barbados Belarus Belgium Belize Benin Bermuda Bhutan Bolivia (Plurinational State of) Bonaire, Sint Eustatius and Saba Bosnia and Herzegovina Botswana Brazil British Virgin Islands Brunei Darussalam Bulgaria Burkina Faso Burundi Cabo Verde Cambodia Cameroon Canada Cayman Islands Central African Republic Chad Channel Islands Chile China China, Hong Kong SAR China, Macao SAR Colombia Comoros Congo Cook Islands Costa Rica Côte d'Ivoire Croatia Cuba Curaçao Cyprus Czechia Dem. People's Republic of Korea Democratic Republic of the Congo Denmark Djibouti Dominica Dominican Republic Ecuador Egypt El Salvador Equatorial Guinea Eritrea Estonia Eswatini Ethiopia Falkland Islands (Malvinas) Faroe Islands Fiji Finland France French Guiana French Polynesia Gabon Gambia Georgia Germany Ghana Gibraltar Greece Greenland Grenada Guadeloupe Guam Guatemala Guinea Guinea-Bissau Guyana Haiti Holy See Honduras Hungary Iceland India Indonesia Iran (Islamic Republic of) Iraq Ireland Isle of Man Israel Italy Jamaica Japan Jordan Kazakhstan Kenya Kiribati Kuwait Kyrgyzstan Lao People's Democratic Republic Latvia Lebanon Lesotho Liberia Libya Liechtenstein Lithuania Luxembourg Madagascar Malawi Malaysia Maldives Mali Malta Marshall Islands Martinique Mauritania Mauritius Mayotte Mexico Micronesia (Fed. States of) Monaco Mongolia Montenegro Montserrat Morocco Mozambique Myanmar Namibia Nauru Nepal Netherlands New Caledonia New Zealand Nicaragua Niger Nigeria Niue North Macedonia Northern Mariana Islands Norway Oman Pakistan Palau Panama Papua New Guinea Paraguay Peru Philippines Poland Portugal Puerto Rico Qatar Republic of Korea Republic of Moldova Réunion Romania Russian Federation Rwanda Saint Helena Saint Kitts and Nevis Saint Lucia Saint Pierre and Miquelon Saint Vincent and the Grenadines Samoa San Marino Sao Tome and Principe Saudi Arabia Senegal Serbia Seychelles Sierra Leone Singapore Sint Maarten (Dutch part) Slovakia Slovenia Solomon Islands Somalia South Africa South Sudan Spain Sri Lanka State of Palestine Sudan Suriname Sweden Switzerland Syrian Arab Republic Tajikistan Thailand Timor-Leste Togo Tokelau Tonga Trinidad and Tobago Tunisia Turkey Turkmenistan Turks and Caicos Islands Tuvalu Uganda Ukraine United Arab Emirates United Kingdom United Republic of Tanzania United States of America United States Virgin Islands Uruguay Uzbekistan Vanuatu Venezuela (Bolivarian Republic of) Viet Nam Wallis and Futuna Islands Western Sahara Yemen Zambia Zimbabwe Gender
1990 1990001 WORLD NA 900 NA 75349784 3136363 1206819 3111428 70822 400394 992 2023 419447 978 11936 226584 462779 5854 162957 271352 866138 14554 6700 2288909 44776 952057 208159 21023 107062 36999 14540 109247 1579 434396 6818 274022 1754 10718 312656 448037 163218 48685 180680 55785 631094 181 22155 168699 9971 244595 2034070 279068 47166 551046 18021 44856 9111 40452 180711 211545 436549 21279 83642 146953 20547 219309 110121 2418 23129 267523 108362 499236 633491 18468 80985 59586 9591 833652 119 4531 46539 148850 643383 1593 1554 7616 15472 472945 1588365 183784 6323 488860 5736 23645 3238 682 172430 151233 27977 122937 233694 18 89687 195334 8994 2814608 685707 269101 651752 504066 5637 142238 1611601 320821 307392 126581 1544157 127291 2116 36376 269940 245703 115190 216646 45423 256241 36168 1981 188446 17579 33830 58995 286075 495 286891 54249 719 5432 59314 59243 849 2037252 3779 2223 12704 38565 3822 763564 1020313 309201 6718 792 358766 366559 2223 191976 222316 54992 191407 3028 215192 1321 78642 6085 1371727 1589 68180 1538 166350 164512 1199949 803451 908447 625961 6176 816582 335072 1516 435717 7146818 270886 498 11180 11952 245 19142 38259 847 7235 49401 139436 348680 18412 29886 81905 7267 67076 51512 1078 399212 158059 248149 755206 426926 924753 248811 92316 118994 180702 266326 273275 188486 5340 98590 848 16469 109918 184114 1278003 132541 1305 1147 153732 2910993 34846 1918065 95883 869647 1187 120987 742220 2414 102934 601455 2820 75584 165179 42604 98608 Female
1990 1990002 UN development groups NA NA NA .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. Female
1990 1990003 More developed regions b 901 NA 42340418 1575254 569867 49679 69798 372253 522 2002 86978 260 7966 122107 333008 2619 135934 253610 540332 13635 778 67850 42169 845375 194460 18894 6319 36927 201 22110 1435 431026 1327 168672 74 3282 59672 2751 2222 43505 122501 25516 601645 128 4480 1477 9905 102127 738043 262012 7456 207772 9651 27884 9083 28559 24866 209773 406448 19262 78160 142135 7953 45213 106404 1634 12433 221224 84364 110141 250438 4374 12658 57479 279 58267 107 4529 44300 146623 486283 32 187 4455 4079 409412 1365739 53851 6287 419709 5410 13033 81 21 121311 6154 6562 108929 149446 5 65984 180530 8949 597328 158325 216259 59350 499650 5637 80499 1341396 312670 225889 21576 1465350 75825 545 7923 248535 125123 107254 162029 186 8284 11169 1915 171753 17344 25474 5580 96119 141 17973 54105 568 158 3924 55442 0 2013120 1412 2065 12625 38441 2761 671665 41165 22859 671 248 2674 334258 732 183899 93393 1353 58725 3009 189708 138 74829 298 186487 6 46132 911 8625 126327 842509 715062 724340 615648 427 704102 303689 61 352881 4288108 3935 256 5364 5515 222 9005 30900 840 3121 12699 36288 346703 15183 8644 48535 6858 66821 50448 585 32269 117213 1 491248 111353 16722 5612 83012 114275 162845 50289 242001 135064 5078 8087 768 15229 102247 159249 1236547 126578 114 621 34775 2426968 2385 1749026 29781 452835 31 30199 557260 556 66392 527792 141 68 4173 13098 21308 Female
1990 1990004 Less developed regions c 902 NA 33009366 1561109 636952 3061749 1024 28141 470 21 332469 718 3970 104477 129771 3235 27023 17742 325806 919 5922 2221059 2607 106682 13699 2129 100743 72 14339 87137 144 3370 5491 105350 1680 7436 252984 445286 160996 5180 58179 30269 29449 53 17675 167222 66 142468 1296027 17056 39710 343274 8370 16972 28 11893 155845 1772 30101 2017 5482 4818 12594 174096 3717 784 10696 46299 23998 389095 383053 14094 68327 2107 9312 775385 12 2 2239 2227 157100 1561 1367 3161 11393 63533 222626 129933 36 69151 326 10612 3157 661 51119 145079 21415 14008 84248 13 23703 14804 45 2217280 527382 52842 592402 4416 0 61739 270205 8151 81503 105005 78807 51466 1571 28453 21405 120580 7936 54617 45237 247957 24999 66 16693 235 8356 53415 189956 354 268918 144 151 5274 55390 3801 849 24132 2367 158 79 124 1061 91899 979148 286342 6047 544 356092 32301 1491 8077 128923 53639 132682 19 25484 1183 3813 5787 1185240 1583 22048 627 157725 38185 357440 88389 184107 10313 5749 112480 31383 1455 82836 2858710 266951 242 5816 6437 23 10137 7359 7 4114 36702 103148 1977 3229 21242 33370 409 255 1064 493 366943 40846 248148 263958 315573 908031 243199 9304 4719 17857 216037 31274 53422 262 90503 80 1240 7671 24865 41456 5963 1191 526 118957 484025 32461 169039 66102 416812 1156 90788 184960 1858 36542 73663 2679 75516 161006 29506 77300 Female
1990 1990005 Least developed countries d 941 NA 5509988 238252 104494 0 0 3121 0 0 311976 0 0 230 0 0 656 35 0 0 40 759 0 0 470 0 20173 0 8740 0 0 0 374 788 0 0 0 20094 159952 5016 6646 15467 900 0 12633 103838 0 119 116110 23 0 407 3772 12312 0 168 151994 0 635 0 2 0 18 129378 83 429 0 1061 0 14487 0 203 64537 0 44 718456 0 0 345 0 18426 0 0 2458 6388 0 2212 33307 0 19 0 0 0 0 0 82808 20697 0 0 0 0 9 0 304187 34900 0 2244 1 0 0 705 0 4405 0 0 45228 571 20 0 27066 0 2939 1481 238230 1803 0 0 0 5803 20470 42652 0 65506 0 0 0 51977 43 0 175 0 0 0 0 0 1933 643873 119906 1397 528 4572 252 164 216 0 24143 56763 0 0 0 1950 0 6780 0 0 568 0 143 342 0 3043 843 0 183 0 450 0 693 263493 0 0 0 0 0 3 0 1560 1094 91335 0 3126 19860 4905 0 0 7 44 356631 10369 241547 709 47 1215 119995 0 542 286 1080 17658 15377 0 20612 0 10 0 129 5 0 0 174 73783 45 38 7204 34211 17777 0 174 883 6 1185 34583 0 0 182 15560 37835 Female
1990 1990006 Less developed regions, excluding least developed countries NA 934 NA 27499378 1322857 532458 3061749 1024 25020 470 21 20493 718 3970 104247 129771 3235 26367 17707 325806 919 5882 2220300 2607 106682 13229 2129 80570 72 5599 87137 144 3370 5117 104562 1680 7436 252984 425192 1044 164 51533 14802 28549 53 5042 63384 66 142349 1179917 17033 39710 342867 4598 4660 28 11725 3851 1772 29466 2017 5480 4818 12576 44718 3634 355 10696 45238 23998 374608 383053 13891 3790 2107 9268 56929 12 2 1894 2227 138674 1561 1367 703 5005 63533 220414 96626 36 69132 326 10612 3157 661 51119 62271 718 14008 84248 13 23703 14795 45 1913093 492482 52842 590158 4415 0 61739 269500 8151 77098 105005 78807 6238 1000 28433 21405 93514 7936 51678 43756 9727 23196 66 16693 235 2553 32945 147304 354 203412 144 151 5274 3413 3758 849 23957 2367 158 79 124 1061 89966 335275 166436 4650 16 351520 32049 1327 7861 128923 29496 75919 19 25484 1183 1863 5787 1178460 1583 22048 59 157725 38042 357098 88389 181064 9470 5749 112297 31383 1005 82836 2858017 3458 242 5816 6437 23 10137 7356 7 2554 35608 11813 1977 103 1382 28465 409 255 1057 449 10312 30477 6601 263249 315526 906816 123204 9304 4177 17571 214957 13616 38045 262 69891 80 1230 7671 24736 41451 5963 1191 352 45174 483980 32423 161835 31891 399035 1156 90614 184077 1852 35357 39080 2679 75516 160824 13946 39465 Female



Countrymap<- read.csv("continents-according-to-our-world-in-data.csv", header = TRUE, stringsAsFactors = FALSE)
Countrymap<- Countrymap %>%  select (Entity, X)
head(Countrymap)

The Male and Female migrants data are then merged together into one dataset “All_migrants” by row. Also, renamed the 3rd column for convenience.

All_migrants<- rbind(Male_migrant,Female_migrant)
names(All_migrants)[3] <- "Destination"
head(All_migrants) %>% kable(booktabs= T) %>% kable_styling(latex_options = c("striped", "scale_down")) %>% scroll_box(width="100%",height="350px")
Year Sort order Destination Notes Code Type of data(a) Total Other South Other North Afghanistan Albania Algeria American Samoa Andorra Angola Anguilla Antigua and Barbuda Argentina Armenia Aruba Australia Austria Azerbaijan Bahamas Bahrain Bangladesh Barbados Belarus Belgium Belize Benin Bermuda Bhutan Bolivia (Plurinational State of) Bonaire, Sint Eustatius and Saba Bosnia and Herzegovina Botswana Brazil British Virgin Islands Brunei Darussalam Bulgaria Burkina Faso Burundi Cabo Verde Cambodia Cameroon Canada Cayman Islands Central African Republic Chad Channel Islands Chile China China, Hong Kong SAR China, Macao SAR Colombia Comoros Congo Cook Islands Costa Rica Côte d'Ivoire Croatia Cuba Curaçao Cyprus Czechia Dem. People's Republic of Korea Democratic Republic of the Congo Denmark Djibouti Dominica Dominican Republic Ecuador Egypt El Salvador Equatorial Guinea Eritrea Estonia Eswatini Ethiopia Falkland Islands (Malvinas) Faroe Islands Fiji Finland France French Guiana French Polynesia Gabon Gambia Georgia Germany Ghana Gibraltar Greece Greenland Grenada Guadeloupe Guam Guatemala Guinea Guinea-Bissau Guyana Haiti Holy See Honduras Hungary Iceland India Indonesia Iran (Islamic Republic of) Iraq Ireland Isle of Man Israel Italy Jamaica Japan Jordan Kazakhstan Kenya Kiribati Kuwait Kyrgyzstan Lao People's Democratic Republic Latvia Lebanon Lesotho Liberia Libya Liechtenstein Lithuania Luxembourg Madagascar Malawi Malaysia Maldives Mali Malta Marshall Islands Martinique Mauritania Mauritius Mayotte Mexico Micronesia (Fed. States of) Monaco Mongolia Montenegro Montserrat Morocco Mozambique Myanmar Namibia Nauru Nepal Netherlands New Caledonia New Zealand Nicaragua Niger Nigeria Niue North Macedonia Northern Mariana Islands Norway Oman Pakistan Palau Panama Papua New Guinea Paraguay Peru Philippines Poland Portugal Puerto Rico Qatar Republic of Korea Republic of Moldova Réunion Romania Russian Federation Rwanda Saint Helena Saint Kitts and Nevis Saint Lucia Saint Pierre and Miquelon Saint Vincent and the Grenadines Samoa San Marino Sao Tome and Principe Saudi Arabia Senegal Serbia Seychelles Sierra Leone Singapore Sint Maarten (Dutch part) Slovakia Slovenia Solomon Islands Somalia South Africa South Sudan Spain Sri Lanka State of Palestine Sudan Suriname Sweden Switzerland Syrian Arab Republic Tajikistan Thailand Timor-Leste Togo Tokelau Tonga Trinidad and Tobago Tunisia Turkey Turkmenistan Turks and Caicos Islands Tuvalu Uganda Ukraine United Arab Emirates United Kingdom United Republic of Tanzania United States of America United States Virgin Islands Uruguay Uzbekistan Vanuatu Venezuela (Bolivarian Republic of) Viet Nam Wallis and Futuna Islands Western Sahara Yemen Zambia Zimbabwe Gender
1990 1990001 WORLD NA 900 NA 77661689 3412163 1159981 3711922 109462 521333 1049 1769 405495 1069 9817 203585 436870 4742 140739 234736 767943 10628 6120 3162922 40155 815549 157201 15094 127252 34703 13925 115446 1627 427370 19235 226370 1340 15605 300437 573295 173900 42683 174750 60068 367069 192 24207 168103 8755 248431 2197578 272012 48482 458889 22062 51516 8377 29259 185637 214262 399247 21911 90736 130307 19237 217217 91640 2890 19308 198693 105646 822942 608584 17710 89618 54319 25590 856303 141 2989 43627 101915 572512 1251 1595 7736 20808 446509 1341083 187378 5671 533599 3774 19604 2590 694 175902 201530 27432 110794 295179 13 66907 192180 8627 3808569 952658 362238 854950 413220 5098 139359 1739405 268189 301529 187416 1427482 123049 1937 45235 252638 237318 99944 292677 145916 260645 40088 1447 152604 18562 25594 84442 276687 1698 360545 56497 707 5609 75174 51465 986 2358113 3935 2256 11762 38819 3366 984687 1202056 376109 9361 627 389294 357079 1928 196197 219810 94787 255399 2832 217104 1204 59894 6450 1971601 1369 66563 1573 131629 150342 833735 706964 965010 574860 6028 808147 290611 1571 377349 5516075 276832 386 9534 10053 240 17907 36602 572 6742 57765 230827 393867 17221 31968 74563 7556 65930 39984 1134 448855 150244 266794 683813 459025 888310 336129 87554 87854 145574 355555 264426 122822 5921 95240 836 16197 87603 281462 1362030 127446 1006 1203 157870 2634767 44699 1876268 107187 869586 1175 116499 685800 2646 83012 636418 3664 92655 290313 42599 105757 Male
1990 1990002 UN development groups NA NA NA .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. Male
1990 1990003 More developed regions b 901 NA 40426798 1809849 507312 69707 108188 494762 505 1735 80403 280 6595 101201 321103 2020 109322 218340 516211 9741 1005 93241 37394 724917 143609 13289 8519 34623 353 21162 1465 423323 1516 114297 84 3341 63086 3635 2398 36722 114773 24650 336941 141 4634 2131 8720 89567 722302 254737 6926 157368 9295 33711 8358 19481 24371 212337 368086 19805 85825 126337 7690 50315 87959 1832 11381 166342 81237 159680 257214 4069 12907 52689 267 58633 130 2989 41697 100465 394850 29 137 4262 8577 392298 1123196 73769 5633 470860 3587 10793 81 22 123986 8558 9544 97936 145320 5 48351 179630 8584 635626 150834 302178 85827 409302 5098 88873 1448019 262462 204669 48955 1368478 78800 444 8502 234508 126654 93400 208539 179 10070 14153 1335 138545 18435 18026 6004 92098 163 33381 56397 547 158 9331 46175 0 2337466 1352 2135 11675 38702 2413 896077 37792 21839 633 217 4503 326551 536 187589 85610 2080 89477 2812 191059 136 55383 416 260857 6 44012 934 5946 101746 507133 631908 751116 565279 477 678290 263476 64 308201 3278092 4492 283 4522 4593 211 9419 28658 536 2760 12206 94339 392273 13807 11074 42019 7053 65626 39016 530 35133 107091 0 425753 148767 18878 9471 77368 82846 125358 76064 229232 70955 5436 11271 755 14745 80657 257235 1311909 122635 107 550 36354 2241388 3215 1713505 31252 436579 39 26639 521303 461 48599 557518 743 265 7284 12964 19649 Male
1990 1990004 Less developed regions c 902 NA 37234891 1602314 652669 3642215 1274 26571 544 34 325092 789 3222 102384 115767 2722 31417 16396 251732 887 5115 3069681 2761 90632 13592 1805 118733 80 13572 94284 162 4047 17719 112073 1256 12264 237351 569660 171502 5961 59977 35418 30128 51 19573 165972 35 158864 1475276 17275 41556 301521 12767 17805 19 9778 161266 1925 31161 2106 4911 3970 11547 166902 3681 1058 7927 32351 24409 663262 351370 13641 76711 1630 25323 797670 11 0 1930 1450 177662 1222 1458 3474 12231 54211 217887 113609 38 62739 187 8811 2509 672 51916 192972 17888 12858 149859 8 18556 12550 43 3172943 801824 60060 769123 3918 0 50486 291386 5727 96860 138461 59004 44249 1493 36733 18130 110664 6544 84138 145737 250575 25935 112 14059 127 7568 78438 184589 1535 327164 100 160 5451 65843 5290 986 20647 2583 121 87 117 953 88610 1164264 354270 8728 410 384791 30528 1392 8608 134200 92707 165922 20 26045 1068 4511 6034 1710744 1363 22551 639 125683 48596 326602 75056 213894 9581 5551 129857 27135 1507 69148 2237983 272340 103 5012 5460 29 8488 7944 36 3982 45559 136488 1594 3414 20894 32544 503 304 968 604 413722 43153 266794 258060 310258 869432 326658 10186 5008 20216 279491 35194 51867 485 83969 81 1452 6946 24227 50121 4811 899 653 121516 393379 41484 162763 75935 433007 1136 89860 164497 2185 34413 78900 2921 92390 283029 29635 86108 Male
1990 1990005 Least developed countries d 941 NA 5550233 244501 135262 0 0 2501 0 0 296132 0 0 296 0 0 809 155 0 0 49 1287 0 0 503 0 21560 0 8065 0 0 0 278 843 0 0 0 23068 169652 5780 7676 17913 976 0 13807 104323 0 214 129813 31 0 421 4777 12856 0 106 156487 0 858 0 3 0 60 127832 106 475 0 1345 0 16095 0 152 69934 0 58 714494 0 0 376 0 20115 0 0 2815 6676 0 2564 25683 0 21 0 0 0 0 0 118144 16933 0 0 0 0 1 0 158283 40346 0 2776 0 0 0 1696 0 5324 0 0 37703 483 9 0 31777 0 4398 1473 239503 1954 0 0 0 5007 27145 50228 0 66751 0 0 0 55824 70 0 131 0 0 0 0 0 1778 621480 106389 1683 400 5453 296 128 271 0 31791 57513 0 0 0 2299 0 10535 0 0 592 0 208 476 0 5151 703 0 171 0 507 0 772 268902 0 0 0 0 0 18 0 1659 1038 104819 0 3300 19179 5773 0 0 8 39 400790 10672 257061 1069 68 1482 124612 0 628 400 1313 22879 16699 0 12256 0 14 0 92 1 0 0 203 75525 39 24 8556 38482 20539 0 112 1144 3 1325 36996 0 0 175 10694 37287 Male
1990 1990006 Less developed regions, excluding least developed countries NA 934 NA 31684658 1357813 517407 3642215 1274 24070 544 34 28960 789 3222 102088 115767 2722 30608 16241 251732 887 5066 3068394 2761 90632 13089 1805 97173 80 5507 94284 162 4047 17441 111230 1256 12264 237351 546592 1850 181 52301 17505 29152 51 5766 61649 35 158650 1345463 17244 41556 301100 7990 4949 19 9672 4779 1925 30303 2106 4908 3970 11487 39070 3575 583 7927 31006 24409 647167 351370 13489 6777 1630 25265 83176 11 0 1554 1450 157547 1222 1458 659 5555 54211 215323 87926 38 62718 187 8811 2509 672 51916 74828 955 12858 149859 8 18556 12549 43 3014660 761478 60060 766347 3918 0 50486 289690 5727 91536 138461 59004 6546 1010 36724 18130 78887 6544 79740 144264 11072 23981 112 14059 127 2561 51293 134361 1535 260413 100 160 5451 10019 5220 986 20516 2583 121 87 117 953 86832 542784 247881 7045 10 379338 30232 1264 8337 134200 60916 108409 20 26045 1068 2212 6034 1700209 1363 22551 47 125683 48388 326126 75056 208743 8878 5551 129686 27135 1000 69148 2237211 3438 103 5012 5460 29 8488 7926 36 2323 44521 31669 1594 114 1715 26771 503 304 960 565 12932 32481 9733 256991 310190 867950 202046 10186 4380 19816 278178 12315 35168 485 71713 81 1438 6946 24135 50120 4811 899 450 45991 393340 41460 154207 37453 412468 1136 89748 163353 2182 33088 41904 2921 92390 282854 18941 48821 Male

Tidy & Manipulate Data I

‘All_migrants’ dataset contains data that sums up region, country or area wise data. Exluding these as these will result in data duplicity.

All_migrants <- All_migrants %>% filter(`Type of data (a)`!= "")

Eleminating the columns which are not necessary for analysis.

All_migrants <- All_migrants %>% select(-c(`Sort\r\norder`, Notes, Code, `Type of data (a)`, Total, `Other South`, `Other North`))

head(All_migrants) %>% kable(booktabs= T) %>% kable_styling(latex_options = c("striped", "scale_down")) %>% scroll_box(width="100%",height="350px")
Year Destination Afghanistan Albania Algeria American Samoa Andorra Angola Anguilla Antigua and Barbuda Argentina Armenia Aruba Australia Austria Azerbaijan Bahamas Bahrain Bangladesh Barbados Belarus Belgium Belize Benin Bermuda Bhutan Bolivia (Plurinational State of) Bonaire, Sint Eustatius and Saba Bosnia and Herzegovina Botswana Brazil British Virgin Islands Brunei Darussalam Bulgaria Burkina Faso Burundi Cabo Verde Cambodia Cameroon Canada Cayman Islands Central African Republic Chad Channel Islands Chile China China, Hong Kong SAR China, Macao SAR Colombia Comoros Congo Cook Islands Costa Rica Côte d'Ivoire Croatia Cuba Curaçao Cyprus Czechia Dem. People's Republic of Korea Democratic Republic of the Congo Denmark Djibouti Dominica Dominican Republic Ecuador Egypt El Salvador Equatorial Guinea Eritrea Estonia Eswatini Ethiopia Falkland Islands (Malvinas) Faroe Islands Fiji Finland France French Guiana French Polynesia Gabon Gambia Georgia Germany Ghana Gibraltar Greece Greenland Grenada Guadeloupe Guam Guatemala Guinea Guinea-Bissau Guyana Haiti Holy See Honduras Hungary Iceland India Indonesia Iran (Islamic Republic of) Iraq Ireland Isle of Man Israel Italy Jamaica Japan Jordan Kazakhstan Kenya Kiribati Kuwait Kyrgyzstan Lao People's Democratic Republic Latvia Lebanon Lesotho Liberia Libya Liechtenstein Lithuania Luxembourg Madagascar Malawi Malaysia Maldives Mali Malta Marshall Islands Martinique Mauritania Mauritius Mayotte Mexico Micronesia (Fed. States of) Monaco Mongolia Montenegro Montserrat Morocco Mozambique Myanmar Namibia Nauru Nepal Netherlands New Caledonia New Zealand Nicaragua Niger Nigeria Niue North Macedonia Northern Mariana Islands Norway Oman Pakistan Palau Panama Papua New Guinea Paraguay Peru Philippines Poland Portugal Puerto Rico Qatar Republic of Korea Republic of Moldova Réunion Romania Russian Federation Rwanda Saint Helena Saint Kitts and Nevis Saint Lucia Saint Pierre and Miquelon Saint Vincent and the Grenadines Samoa San Marino Sao Tome and Principe Saudi Arabia Senegal Serbia Seychelles Sierra Leone Singapore Sint Maarten (Dutch part) Slovakia Slovenia Solomon Islands Somalia South Africa South Sudan Spain Sri Lanka State of Palestine Sudan Suriname Sweden Switzerland Syrian Arab Republic Tajikistan Thailand Timor-Leste Togo Tokelau Tonga Trinidad and Tobago Tunisia Turkey Turkmenistan Turks and Caicos Islands Tuvalu Uganda Ukraine United Arab Emirates United Kingdom United Republic of Tanzania United States of America United States Virgin Islands Uruguay Uzbekistan Vanuatu Venezuela (Bolivarian Republic of) Viet Nam Wallis and Futuna Islands Western Sahara Yemen Zambia Zimbabwe Gender
1990 WORLD 3711922 109462 521333 1049 1769 405495 1069 9817 203585 436870 4742 140739 234736 767943 10628 6120 3162922 40155 815549 157201 15094 127252 34703 13925 115446 1627 427370 19235 226370 1340 15605 300437 573295 173900 42683 174750 60068 367069 192 24207 168103 8755 248431 2197578 272012 48482 458889 22062 51516 8377 29259 185637 214262 399247 21911 90736 130307 19237 217217 91640 2890 19308 198693 105646 822942 608584 17710 89618 54319 25590 856303 141 2989 43627 101915 572512 1251 1595 7736 20808 446509 1341083 187378 5671 533599 3774 19604 2590 694 175902 201530 27432 110794 295179 13 66907 192180 8627 3808569 952658 362238 854950 413220 5098 139359 1739405 268189 301529 187416 1427482 123049 1937 45235 252638 237318 99944 292677 145916 260645 40088 1447 152604 18562 25594 84442 276687 1698 360545 56497 707 5609 75174 51465 986 2358113 3935 2256 11762 38819 3366 984687 1202056 376109 9361 627 389294 357079 1928 196197 219810 94787 255399 2832 217104 1204 59894 6450 1971601 1369 66563 1573 131629 150342 833735 706964 965010 574860 6028 808147 290611 1571 377349 5516075 276832 386 9534 10053 240 17907 36602 572 6742 57765 230827 393867 17221 31968 74563 7556 65930 39984 1134 448855 150244 266794 683813 459025 888310 336129 87554 87854 145574 355555 264426 122822 5921 95240 836 16197 87603 281462 1362030 127446 1006 1203 157870 2634767 44699 1876268 107187 869586 1175 116499 685800 2646 83012 636418 3664 92655 290313 42599 105757 Male
1990 UN development groups .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. Male
1990 More developed regions 69707 108188 494762 505 1735 80403 280 6595 101201 321103 2020 109322 218340 516211 9741 1005 93241 37394 724917 143609 13289 8519 34623 353 21162 1465 423323 1516 114297 84 3341 63086 3635 2398 36722 114773 24650 336941 141 4634 2131 8720 89567 722302 254737 6926 157368 9295 33711 8358 19481 24371 212337 368086 19805 85825 126337 7690 50315 87959 1832 11381 166342 81237 159680 257214 4069 12907 52689 267 58633 130 2989 41697 100465 394850 29 137 4262 8577 392298 1123196 73769 5633 470860 3587 10793 81 22 123986 8558 9544 97936 145320 5 48351 179630 8584 635626 150834 302178 85827 409302 5098 88873 1448019 262462 204669 48955 1368478 78800 444 8502 234508 126654 93400 208539 179 10070 14153 1335 138545 18435 18026 6004 92098 163 33381 56397 547 158 9331 46175 0 2337466 1352 2135 11675 38702 2413 896077 37792 21839 633 217 4503 326551 536 187589 85610 2080 89477 2812 191059 136 55383 416 260857 6 44012 934 5946 101746 507133 631908 751116 565279 477 678290 263476 64 308201 3278092 4492 283 4522 4593 211 9419 28658 536 2760 12206 94339 392273 13807 11074 42019 7053 65626 39016 530 35133 107091 0 425753 148767 18878 9471 77368 82846 125358 76064 229232 70955 5436 11271 755 14745 80657 257235 1311909 122635 107 550 36354 2241388 3215 1713505 31252 436579 39 26639 521303 461 48599 557518 743 265 7284 12964 19649 Male
1990 Less developed regions 3642215 1274 26571 544 34 325092 789 3222 102384 115767 2722 31417 16396 251732 887 5115 3069681 2761 90632 13592 1805 118733 80 13572 94284 162 4047 17719 112073 1256 12264 237351 569660 171502 5961 59977 35418 30128 51 19573 165972 35 158864 1475276 17275 41556 301521 12767 17805 19 9778 161266 1925 31161 2106 4911 3970 11547 166902 3681 1058 7927 32351 24409 663262 351370 13641 76711 1630 25323 797670 11 0 1930 1450 177662 1222 1458 3474 12231 54211 217887 113609 38 62739 187 8811 2509 672 51916 192972 17888 12858 149859 8 18556 12550 43 3172943 801824 60060 769123 3918 0 50486 291386 5727 96860 138461 59004 44249 1493 36733 18130 110664 6544 84138 145737 250575 25935 112 14059 127 7568 78438 184589 1535 327164 100 160 5451 65843 5290 986 20647 2583 121 87 117 953 88610 1164264 354270 8728 410 384791 30528 1392 8608 134200 92707 165922 20 26045 1068 4511 6034 1710744 1363 22551 639 125683 48596 326602 75056 213894 9581 5551 129857 27135 1507 69148 2237983 272340 103 5012 5460 29 8488 7944 36 3982 45559 136488 1594 3414 20894 32544 503 304 968 604 413722 43153 266794 258060 310258 869432 326658 10186 5008 20216 279491 35194 51867 485 83969 81 1452 6946 24227 50121 4811 899 653 121516 393379 41484 162763 75935 433007 1136 89860 164497 2185 34413 78900 2921 92390 283029 29635 86108 Male
1990 Least developed countries 0 0 2501 0 0 296132 0 0 296 0 0 809 155 0 0 49 1287 0 0 503 0 21560 0 8065 0 0 0 278 843 0 0 0 23068 169652 5780 7676 17913 976 0 13807 104323 0 214 129813 31 0 421 4777 12856 0 106 156487 0 858 0 3 0 60 127832 106 475 0 1345 0 16095 0 152 69934 0 58 714494 0 0 376 0 20115 0 0 2815 6676 0 2564 25683 0 21 0 0 0 0 0 118144 16933 0 0 0 0 1 0 158283 40346 0 2776 0 0 0 1696 0 5324 0 0 37703 483 9 0 31777 0 4398 1473 239503 1954 0 0 0 5007 27145 50228 0 66751 0 0 0 55824 70 0 131 0 0 0 0 0 1778 621480 106389 1683 400 5453 296 128 271 0 31791 57513 0 0 0 2299 0 10535 0 0 592 0 208 476 0 5151 703 0 171 0 507 0 772 268902 0 0 0 0 0 18 0 1659 1038 104819 0 3300 19179 5773 0 0 8 39 400790 10672 257061 1069 68 1482 124612 0 628 400 1313 22879 16699 0 12256 0 14 0 92 1 0 0 203 75525 39 24 8556 38482 20539 0 112 1144 3 1325 36996 0 0 175 10694 37287 Male
1990 Less developed regions, excluding least developed countries 3642215 1274 24070 544 34 28960 789 3222 102088 115767 2722 30608 16241 251732 887 5066 3068394 2761 90632 13089 1805 97173 80 5507 94284 162 4047 17441 111230 1256 12264 237351 546592 1850 181 52301 17505 29152 51 5766 61649 35 158650 1345463 17244 41556 301100 7990 4949 19 9672 4779 1925 30303 2106 4908 3970 11487 39070 3575 583 7927 31006 24409 647167 351370 13489 6777 1630 25265 83176 11 0 1554 1450 157547 1222 1458 659 5555 54211 215323 87926 38 62718 187 8811 2509 672 51916 74828 955 12858 149859 8 18556 12549 43 3014660 761478 60060 766347 3918 0 50486 289690 5727 91536 138461 59004 6546 1010 36724 18130 78887 6544 79740 144264 11072 23981 112 14059 127 2561 51293 134361 1535 260413 100 160 5451 10019 5220 986 20516 2583 121 87 117 953 86832 542784 247881 7045 10 379338 30232 1264 8337 134200 60916 108409 20 26045 1068 2212 6034 1700209 1363 22551 47 125683 48388 326126 75056 208743 8878 5551 129686 27135 1000 69148 2237211 3438 103 5012 5460 29 8488 7926 36 2323 44521 31669 1594 114 1715 26771 503 304 960 565 12932 32481 9733 256991 310190 867950 202046 10186 4380 19816 278178 12315 35168 485 71713 81 1438 6946 24135 50120 4811 899 450 45991 393340 41460 154207 37453 412468 1136 89748 163353 2182 33088 41904 2921 92390 282854 18941 48821 Male

For this analysis we need total number of migrants from each country. In order to achieve this, we will tidy up the data and convert the Country’s names to a single column and the number of migrants in another. We will use gather() function to reorganize the data.

All_migrants <- All_migrants %>% gather(key = Origination, value = "no_of_migrants", -c(Year, Destination, Gender)) 
head(All_migrants) %>% kable(booktabs= T) %>% kable_styling(latex_options = c("striped", "scale_down")) %>% scroll_box(width="100%",height="350px")
Year Destination Gender Origination no_of_migrants
1990 WORLD Male Afghanistan 3711922
1990 UN development groups Male Afghanistan ..
1990 More developed regions Male Afghanistan 69707
1990 Less developed regions Male Afghanistan 3642215
1990 Least developed countries Male Afghanistan 0
1990 Less developed regions, excluding least developed countries Male Afghanistan 3642215

Understanding:

The data contains different data types which needs to be altered according to the analysis need. In this study, we had to transform the data twice.

  1. The variable no_of_migrants is in character format, this needs to be changed to numeric in order to perform mathematical operations on it.
All_migrants$no_of_migrants <- as.numeric(All_migrants$no_of_migrants)
head(All_migrants) %>% kable(booktabs= T) %>% kable_styling(latex_options = c("striped", "scale_down")) %>% scroll_box(width="100%",height="350px")

Year Destination Gender Origination no_of_migrants X
1990 Namibia Male Afghanistan 26 Africa
1990 South Africa Male Afghanistan 37 Africa
1990 Egypt Male Afghanistan 194 Africa
1990 Libya Male Afghanistan 556 Africa
1990 Azerbaijan Male Afghanistan 175 Asia
1990 Bahrain Male Afghanistan 154 Asia

NA

Scan I

Removing observations having “..” values in no_of_migrants.

missingValues<- sapply(All_migrants, is.special)
All_migrants <- All_migrants %>% filter(no_of_migrants != "..")

Removing the “,” from the no_of_migrants in order to translate the data to all digit value. Followed by removal of the NA values.

All_migrants$no_of_migrants <- str_replace_all(All_migrants$no_of_migrants, "\\,","")
All_migrants <- All_migrants %>% filter(!is.na(no_of_migrants))
head(All_migrants) %>% kable(booktabs= T) %>% kable_styling(latex_options = c("striped", "scale_down")) %>% scroll_box(width="100%",height="350px")
Year Destination Gender Origination no_of_migrants
1990 WORLD Male Afghanistan 3711922
1990 More developed regions Male Afghanistan 69707
1990 Less developed regions Male Afghanistan 3642215
1990 Least developed countries Male Afghanistan 0
1990 Less developed regions, excluding least developed countries Male Afghanistan 3642215
1990 High-income countries Male Afghanistan 172416

Merging dataset for grouping:

Merging the Countrymap dataset with the All_migrants in order to map the countries to the respective continents.

All_migrants <- All_migrants %>% inner_join(Countrymap, by = c("Destination" = "Entity"))

head(All_migrants) %>% kable(booktabs= T) %>% kable_styling(latex_options = c("striped", "scale_down")) %>% scroll_box(width="100%",height="350px")
Year Destination Gender Origination no_of_migrants X
1990 Namibia Male Afghanistan 26 Africa
1990 South Africa Male Afghanistan 37 Africa
1990 Egypt Male Afghanistan 194 Africa
1990 Libya Male Afghanistan 556 Africa
1990 Azerbaijan Male Afghanistan 175 Asia
1990 Bahrain Male Afghanistan 154 Asia

Tidy & Manipulate Data II

In this step, we are summing up the total number of migrants from each Continent for every year. A new variable is introduced which contains the total no. of migrant counts in million.

MigrantDetails <- All_migrants %>% group_by(Year, X) %>% summarise(Migrants_in_mil = 
                                            sum(no_of_migrants)) %>% mutate(Migrants_in_mil = Migrants_in_mil/1000000)
names(MigrantDetails)[2]<- "Continent"

head(MigrantDetails) %>% kable(booktabs= T) %>% kable_styling(latex_options = c("striped", "scale_down")) %>% scroll_box(width="100%",height="350px")

Year Continent Migrants_in_mil
1990 Africa 11.476494
1990 Asia 38.001374
1990 Europe 36.095745
1990 North America 6.932044
1990 Oceania 4.683402
1990 South America 3.036789

NA

Understanding (2):

  1. The second conversion of the data is to be done for the Year variable. Year is changed to an ordered factor for further analysis.
MigrantDetails$Year<- factor(MigrantDetails$Year, levels= c(1990,1995,2000,2005,2010,2015,2019), ordered = TRUE)
class(MigrantDetails$Year)
[1] "ordered" "factor" 
MigrantDetails$Year
 [1] 1990 1990 1990 1990 1990 1990 1995 1995 1995 1995 1995 1995 2000 2000 2000 2000 2000 2000 2005 2005 2005 2005
[23] 2005 2005 2010 2010 2010 2010 2010 2010 2015 2015 2015 2015 2015 2015 2019 2019 2019 2019 2019 2019
Levels: 1990 < 1995 < 2000 < 2005 < 2010 < 2015 < 2019

Transform

We will now see if the data is normally distributed or not. Normalisation is necessary in order to avoid any incorrect prediction or keep the error at minimal.

Data distribution of MigrantDetails is shown by plotting a histogram of the data followed by a line graph representing the normality of the data.


hist(MigrantDetails$Migrants_in_mil, probability = TRUE)

curve(dnorm(x, mean = mean(MigrantDetails$Migrants_in_mil),
            sd = sd(MigrantDetails$Migrants_in_mil)) , add = TRUE, col= "red")

NA
NA

As we can see the data is not normally distributed but right skewed instead, we will apply transformation to it in order to achieve normal distribution. We take the logarithmic value of Migrants_in_mil to attain normality.

MigrantDetails$Migrants_in_mil <- log(MigrantDetails$Migrants_in_mil)

hist(MigrantDetails$Migrants_in_mil, probability = TRUE)
curve(dnorm(x, mean = mean(MigrantDetails$Migrants_in_mil),
            sd = sd(MigrantDetails$Migrants_in_mil)) , add = TRUE, col= "red")

Scan II

As we can see the data is normally distributed we will check for the univariate outliers by plotting the data in a boxplot. Note: We are not performing a “Tukey’s method of outlier detection” as the data is normally distributed.

boxplot(MigrantDetails$Migrants_in_mil)

From the bpoxplot we can see that the data doesn’t contain any outliers hence no data modification were done.

Visualisation of the data:

We can view the stats using ggplot. The graph shows the number of migrants migrated from each Continents in a span of 19 years.

ggplot(data=MigrantDetails, aes(x = Continent, 
y = Migrants_in_mil, fill= Year))+
  geom_bar(stat="identity", position=position_dodge() ) + ggtitle("Migration in various Continents from 1990 to 2019")

Conclusion:

From the above analysis we can conclude that migration have increased in all over the world over the time. This data can also be used for analysis of the significance raise in migration continent wise.

Reference:

[1] Country_continent data: https://ourworldindata.org/grapher/continents-according-to-our-world-in-data?overlay=data

[2] UN_MigrantStockByOriginAndDestination_2019 data: https://www.un.org/en/development/desa/population/migration/data/estimates2/estimates17.asp

[3] Kabel styling: https://cran.r-project.org/web/packages/kableExtra/vignettes/awesome_table_in_html.html

[4] R Markdown formatting: https://rstudio.com/wp-content/uploads/2015/02/rmarkdown-cheatsheet.pdf

LS0tCnRpdGxlOiAiTUFUSDIzNDkgU2VtZXN0ZXIgMSwgMjAyMCIKYXV0aG9yOiAiU3VkZXNobmEgTmF5ZWstIFMzODIxMDQxIgpzdWJ0aXRsZTogQXNzaWdubWVudCAyCm91dHB1dDoKICBodG1sX25vdGVib29rOiBkZWZhdWx0Ci0tLQoKIyMjIFJlcXVpcmVkIHBhY2thZ2VzIAoKCmBgYHtyfQpsaWJyYXJ5KHJlYWR4bCkKbGlicmFyeShrbml0cikgCmxpYnJhcnkoc3RyaW5ncikKbGlicmFyeShkcGx5cikKbGlicmFyeSh0aWR5cikKbGlicmFyeShtYWdyaXR0cikKbGlicmFyeShrYWJsZUV4dHJhKQpsaWJyYXJ5KGdncGxvdDIpCmBgYAoKCiMjIyBFeGVjdXRpdmUgU3VtbWFyeSAKClRoaXMgc3R1ZHkgaW52b2x2ZXMgMyBkYXRhc2V0cyBtZXJnZWQgdG9nZXRoZXIgZm9yIGFuYWx5c2lzIHB1cnBvc2UuCgoxLiBVTl9NaWdyYW50U3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