add_minimum_distance() allows you to add the minimum distance (in kilometers) to a dyad-year or state-year data frame. These estimates are recorded in the cow_mindist and gw_mindist data that come with this package. The data are current as of the end of 2015.

add_minimum_distance(data)

Arguments

data

a dyad-year data frame (either "directed" or "non-directed") or state-year data frame

Value

add_minimum_distance() takes a dyad-year or state-year data frame and adds the minimum distance between the first state and the second state (in dyad-year data) or the minimum minimum (sic) distance for a given state in a given year.

Details

The function leans on attributes of the data that are provided by the create_dyadyear() or create_stateyear() function. Make sure that function (or data created by that function) appear at the top of the proverbial pipe.

References

Weidmann, Nils B. and Kristian Skrede Gleditsch. 2010. "Mapping and Measuring Country Shapes: The cshapes Package." The R Journal 2(1): 18-24.

Author

Steven V. Miller

Examples

# \donttest{ # just call `library(tidyverse)` at the top of the your script library(magrittr) cow_ddy %>% add_minimum_distance()
#> Joining, by = c("ccode1", "ccode2", "year")
#> # A tibble: 2,063,670 x 4 #> ccode1 ccode2 year mindist #> <dbl> <dbl> <dbl> <dbl> #> 1 2 20 1920 NA #> 2 2 20 1921 NA #> 3 2 20 1922 NA #> 4 2 20 1923 NA #> 5 2 20 1924 NA #> 6 2 20 1925 NA #> 7 2 20 1926 NA #> 8 2 20 1927 NA #> 9 2 20 1928 NA #> 10 2 20 1929 NA #> # … with 2,063,660 more rows
create_dyadyears(system = "gw") %>% add_minimum_distance()
#> Joining, by = c("gwcode1", "gwcode2", "year")
#> # A tibble: 2,029,660 x 4 #> gwcode1 gwcode2 year mindist #> <dbl> <dbl> <dbl> <dbl> #> 1 2 20 1867 NA #> 2 2 20 1868 NA #> 3 2 20 1869 NA #> 4 2 20 1870 NA #> 5 2 20 1871 NA #> 6 2 20 1872 NA #> 7 2 20 1873 NA #> 8 2 20 1874 NA #> 9 2 20 1875 NA #> 10 2 20 1876 NA #> # … with 2,029,650 more rows
create_stateyears(system ="gw") %>% add_minimum_distance()
#> Joining, by = c("gwcode", "year")
#> # A tibble: 18,289 x 4 #> gwcode statename year minmindist #> <dbl> <chr> <dbl> <dbl> #> 1 2 United States of America 1816 NA #> 2 2 United States of America 1817 NA #> 3 2 United States of America 1818 NA #> 4 2 United States of America 1819 NA #> 5 2 United States of America 1820 NA #> 6 2 United States of America 1821 NA #> 7 2 United States of America 1822 NA #> 8 2 United States of America 1823 NA #> 9 2 United States of America 1824 NA #> 10 2 United States of America 1825 NA #> # … with 18,279 more rows
# }