Learn R Programming

peacesciencer (version 0.4.0)

add_capital_distance: Add capital-to-capital distance to a dyad-year or state-year data frame

Description

add_capital_distance() allows you to add capital-to-capital distance to a dyad-year or state-year data frame. The capitals are coded in the capitals data frame, 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 dyad-year data frame (either "directed" or "non-directed") or state-year data frame

Value

add_capital_distance() takes a dyad-year or 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 capitals 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.

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.

Examples

Run this code
# NOT RUN {
# }
# NOT RUN {
# just call `library(tidyverse)` at the top of the your script
library(magrittr)
cow_ddy %>% add_capital_distance()

create_stateyears() %>% add_capital_distance()
# }
# NOT RUN {

# }

Run the code above in your browser using DataLab