Learn R Programming

peacesciencer (version 1.2.0)

add_capital_distance: 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, state-year) data frame. 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, transsum = "first")

add_cap_dist(...)

Value

add_capital_distance() takes a (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.

Arguments

data

a data frame with appropriate peacesciencer attributes

transsum

a character vector with one of the following acceptable inputs: "first" ("jan1") or "last" ("dec31"). Determines what to do for a yearly summary in the case of a capital transition. "first" ("jan1") selects the first capital coordinate observed in a given year while "last" ("dec31") selects the last capital coordinate observed in a given year. Default is "first" ("jan1"). See details section for more.

...

optional, only to make the shortcut (add_cap_dist()) work

Author

Steven V. Miller

Details

The function leans on attributes of the data that are provided by one of the "create" functions in this package (e.g. create_dyadyears() or create_stateyears()).

Be advised that "jan1" and "dec31" are alternate specifications for "first" and "last" respectively and exist as kind of a nudge for what you want to conceptualize the inputs for your year to be what is observed at its start or at its end. Obviously, there was no Jan. 1, 1954 or Dec. 31, 1875 for the Republic of Vietnam.

Examples

Run this code

# \donttest{
# just call `library(tidyverse)` at the top of the your script
library(magrittr)
cow_ddy %>% add_capital_distance()

create_stateyears() %>% add_capital_distance()
# }


Run the code above in your browser using DataLab