Skip to contents

get_migration is a function that allows the user to get a demographic dataset regarding migration based on the given parameters.

Usage

get_migration(
  v_state = "National",
  v_year = c(2000, 2010, 2025),
  v_sex = c("Female", "Male", "Total"),
  v_age = c(0, 15, 24, 36),
  v_type = c("Interstate", "International", "Total"),
  age_groups = TRUE
)

Arguments

v_state

State(s) of desired data.

v_year

Year(s) of desired data. Must have numbers between 1970 and 2050.

v_sex

Vector selecting sex. Options: Female, Male and Total.

v_age

Specifies the age bins to aggregate and return.

v_type

Indicates whether type of migration to include. It can be Interstate migration, International migration or Total migration.

age_groups

Specifies whether to aggregate the output by age groups.

Value

A demographic dataset containing the selected year, the state, the state code (CVE_GEO), the age (age group, when age_groups = TRUE), the type of migration, the number of emigrants, the number of immigrants, migration balance (immigrants - emigrants), and the rate of emigration and immigration, respectively.

Examples


get_migration(v_state = c("Yucatan", "Sonora"),
              v_year = 2015,
              v_sex = "Total",
              v_age = c(0, 25, 35, 45),
              v_type = "International",
              age_groups = TRUE)
#> # A tibble: 8 x 12
#>    year state   CVE_GEO sex   age_group type  emigrants immigrants net_migration
#>   <int> <chr>     <dbl> <chr> <fct>     <chr>     <dbl>      <dbl>         <dbl>
#> 1  2015 Sonora       26 Total [0,25]    Inte~      2137       2282           145
#> 2  2015 Sonora       26 Total (25,35]   Inte~       982       1258           276
#> 3  2015 Sonora       26 Total (35,45]   Inte~       519        833           314
#> 4  2015 Sonora       26 Total (45,Inf]  Inte~       636        877           241
#> 5  2015 Yucatan      31 Total [0,25]    Inte~       951        466          -485
#> 6  2015 Yucatan      31 Total (25,35]   Inte~       437        260          -177
#> 7  2015 Yucatan      31 Total (35,45]   Inte~       232        172           -60
#> 8  2015 Yucatan      31 Total (45,Inf]  Inte~       284        179          -105
#> # ... with 3 more variables: em_rate <dbl>, im_rate <dbl>, nm_rate <dbl>

get_migration(v_state = "Mexico City",
              v_year = c(2000, 2010),
              v_sex = "Female",
              v_age = c(0, 15, 35, 45, 75),
              v_type = c("Interstate", "International", "Total"),
              age_groups = FALSE)
#> # A tibble: 30 x 12
#>     year state      CVE_GEO sex     age emigrants immigrants type  net_migration
#>    <int> <chr>        <dbl> <chr> <int>     <dbl>      <dbl> <chr>         <dbl>
#>  1  2000 Mexico Ci~       9 Fema~     0       160         77 Inte~           -83
#>  2  2000 Mexico Ci~       9 Fema~     0      4048        746 Inte~         -3302
#>  3  2000 Mexico Ci~       9 Fema~     0      4209        823 Total         -3386
#>  4  2000 Mexico Ci~       9 Fema~    15       408         49 Inte~          -359
#>  5  2000 Mexico Ci~       9 Fema~    15       859        783 Inte~           -76
#>  6  2000 Mexico Ci~       9 Fema~    15      1267        831 Total          -436
#>  7  2000 Mexico Ci~       9 Fema~    35       101         84 Inte~           -17
#>  8  2000 Mexico Ci~       9 Fema~    35       985        291 Inte~          -694
#>  9  2000 Mexico Ci~       9 Fema~    35      1086        375 Total          -711
#> 10  2000 Mexico Ci~       9 Fema~    45        42         47 Inte~             5
#> # ... with 20 more rows, and 3 more variables: em_rate <dbl>, im_rate <dbl>,
#> #   nm_rate <dbl>