Skip to contents

add_lead() allows you to add some data recorded in the LEAD data to your leader-year or leader-dyad-year data.

Usage

add_lead(data, keep)

Arguments

data

a leader-year or leader-dyad-year data frame

keep

an optional parameter, specified as a character vector, about what leader attributes the user wants to return from this function. If keep is not specified, everything from the LEAD data in this package is returned. Otherwise, the function subsets the LEAD data to just what the user wants.

Value

add_lead() takes a leader-year or leader-dyad-year data frame and adds some data recorded in the LEAD data to it. For leader-dyad-year data, suffices of "1" and "2" are added to the data to indicate attributes of the first leader (obsid1) or the second leader (obsid2), respectively.

References

Ellis, Carli Mortenson, Michael C. Horowitz, and Allan C. Stam. 2015. "Introducing the LEAD Data Set." International Interactions 41(4): 718--741.

Author

Steven V. Miller

Examples


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

create_leaderyears() %>% add_lead()
#> Joining with `by = join_by(obsid)`
#> # A tibble: 17,686 × 18
#>    obsid    leader gwcode gender leaderage  year yrinoffice leveledu milservice
#>    <chr>    <chr>   <dbl> <chr>      <dbl> <dbl>      <dbl>    <dbl>      <dbl>
#>  1 USA-1869 Grant       2 M             47  1869          1        2          1
#>  2 USA-1869 Grant       2 M             48  1870          2        2          1
#>  3 USA-1869 Grant       2 M             49  1871          3        2          1
#>  4 USA-1869 Grant       2 M             50  1872          4        2          1
#>  5 USA-1869 Grant       2 M             51  1873          5        2          1
#>  6 USA-1869 Grant       2 M             52  1874          6        2          1
#>  7 USA-1869 Grant       2 M             53  1875          7        2          1
#>  8 USA-1869 Grant       2 M             54  1876          8        2          1
#>  9 USA-1869 Grant       2 M             55  1877          9        2          1
#> 10 USA-1877 Hayes       2 M             55  1877          1        3          1
#> # ℹ 17,676 more rows
#> # ℹ 9 more variables: combat <dbl>, rebel <dbl>, warwin <dbl>, warloss <dbl>,
#> #   rebelwin <dbl>, rebelloss <dbl>, yrsexper <dbl>, physhealth <dbl>,
#> #   mentalhealth <dbl>

create_leaderyears() %>% add_lead(keep = c("yrsexper"))
#> Joining with `by = join_by(obsid)`
#> # A tibble: 17,686 × 8
#>    obsid    leader gwcode gender leaderage  year yrinoffice yrsexper
#>    <chr>    <chr>   <dbl> <chr>      <dbl> <dbl>      <dbl>    <dbl>
#>  1 USA-1869 Grant       2 M             47  1869          1        0
#>  2 USA-1869 Grant       2 M             48  1870          2        0
#>  3 USA-1869 Grant       2 M             49  1871          3        0
#>  4 USA-1869 Grant       2 M             50  1872          4        0
#>  5 USA-1869 Grant       2 M             51  1873          5        0
#>  6 USA-1869 Grant       2 M             52  1874          6        0
#>  7 USA-1869 Grant       2 M             53  1875          7        0
#>  8 USA-1869 Grant       2 M             54  1876          8        0
#>  9 USA-1869 Grant       2 M             55  1877          9        0
#> 10 USA-1877 Hayes       2 M             55  1877          1       12
#> # ℹ 17,676 more rows
# }