View source: R/add_capital_distance.R
add_capital_distance | R Documentation |
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.
add_capital_distance(data)
data |
a data frame with appropriate peacesciencer attributes |
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()
).
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.
Steven V. Miller
# just call `library(tidyverse)` at the top of the your script
library(magrittr)
cow_ddy %>% add_capital_distance()
create_stateyears() %>% add_capital_distance()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.