Skip to contents

add_minimum_distance() allows you to add the minimum distance (in kilometers) to a (dyad-year, leader-year, leader-dyad-year, 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 2019.

Usage

add_minimum_distance(data)

Arguments

data

a data frame with appropriate peacesciencer attributes

Value

add_minimum_distance() takes a (dyad-year, leader-year, leader-dyad-year, 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 one of the "create" functions in this package (e.g. create_dyadyear() or create_stateyear()).

References

Schvitz, Guy, Luc Girardin, Seraina Ruegger, Nils B. Weidmann, Lars-Erik Cederman, and Kristian Skrede Gleditsch. 2022. "Mapping The International System, 1886-2017: The CShapes 2.0 Dataset." Journal of Conflict Resolution. 66(1): 144-161.

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 with `by = join_by(ccode1, ccode2, year)`
#> # A tibble: 2,139,270 × 4
#>    ccode1 ccode2  year mindist
#>     <dbl>  <dbl> <dbl>   <dbl>
#>  1      2     20  1920      NA
#>  2      2     20  1921       0
#>  3      2     20  1922       0
#>  4      2     20  1923       0
#>  5      2     20  1924       0
#>  6      2     20  1925       0
#>  7      2     20  1926       0
#>  8      2     20  1927       0
#>  9      2     20  1928       0
#> 10      2     20  1929       0
#> # ℹ 2,139,260 more rows

create_dyadyears(system = "gw") %>% add_minimum_distance()
#> Joining with `by = join_by(gwcode1, gwcode2, year)`
#> Joining with `by = join_by(gwcode1, gwcode2, year)`
#> # A tibble: 2,089,826 × 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
#> # ℹ 2,089,816 more rows

create_stateyears(system ="gw") %>% add_minimum_distance()
#> Joining with `by = join_by(gwcode, year)`
#> # A tibble: 18,637 × 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
#> # ℹ 18,627 more rows
# }