add_capital_distance {peacesciencer} | R Documentation |
Add capital-to-capital distance to a data frame
Description
add_capital_distance()
allows you to add capital-to-capital
distance to a (dyad-year, leader-year, leader-dyad-year, state-year) data frame. The capitals are coded in the
cow_capitals
and gw_capitals
data frames, along with their latitudes and longitudes. The distance variable that
emerges capdist
is calculated using the "Vincenty" method (i.e. "as the crow
flies") and is expressed in kilometers.
Usage
add_capital_distance(data)
Arguments
data |
a data frame with appropriate peacesciencer attributes |
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()
).
Value
add_capital_distance()
takes a (dyad-year, leader-year, leader-dyad-year, state-year) data frame and adds the
capital-to-capital distance between the first state and the second state (in dyad-year data) or the minimum
capital-to-capital distance for a given state in a given year. A minor
note about this function: cases of capital transition are recorded in the
underlying data but, in the conversion to capital-years (and eventual
merging into a dyad-year data frame), the Jan. 1 capital is used for calculating
distances.
Author(s)
Steven V. Miller
Examples
# just call `library(tidyverse)` at the top of the your script
library(magrittr)
cow_ddy %>% add_capital_distance()
create_stateyears() %>% add_capital_distance()