Helper to look up state list entries by country code or name

sfind(x, list = "both")

Arguments

x

The search string or number.

list

Which state list to search (both, GW, or COW only)

Examples

# Works with either integer or strings
sfind(325)
#>     list ccode code3c   country_name      start        end microstate
#> 60    GW   325    ITA Italy/Sardinia 1816-01-01 9999-12-31      FALSE
#> 317  COW   325    ITA          Italy 1816-01-01 9999-12-31      FALSE
sfind("ALG")
#>     list ccode code3c country_name      start        end microstate
#> 151   GW   615    ALG      Algeria 1816-01-01 1830-07-05      FALSE
#> 152   GW   615    ALG      Algeria 1962-07-05 9999-12-31      FALSE
#> 411  COW   615    ALG      Algeria 1962-07-05 9999-12-31      FALSE
sfind("Algeria")
#>     list ccode code3c country_name      start        end microstate
#> 151   GW   615    ALG      Algeria 1816-01-01 1830-07-05      FALSE
#> 152   GW   615    ALG      Algeria 1962-07-05 9999-12-31      FALSE
#> 411  COW   615    ALG      Algeria 1962-07-05 9999-12-31      FALSE

# Search strings are treated as regular expressions (see stringr::str_detect)
sfind("Germany")
#>     list ccode code3c      country_name      start        end microstate
#> 44    GW   255    GMY Germany (Prussia) 1816-01-01 1945-05-07      FALSE
#> 297  COW   255    GMY           Germany 1816-01-01 1945-05-08      FALSE
#> 298  COW   255    GMY           Germany 1990-10-03 9999-12-31      FALSE
sfind("German")
#>     list ccode code3c               country_name      start        end
#> 44    GW   255    GMY          Germany (Prussia) 1816-01-01 1945-05-07
#> 45    GW   260    GFR    German Federal Republic 1949-09-21 9999-12-31
#> 46    GW   265    GDR German Democratic Republic 1949-10-05 1990-10-02
#> 297  COW   255    GMY                    Germany 1816-01-01 1945-05-08
#> 298  COW   255    GMY                    Germany 1990-10-03 9999-12-31
#> 299  COW   260    GFR    German Federal Republic 1955-05-05 1990-10-02
#> 300  COW   265    GDR German Democratic Republic 1954-03-25 1990-10-02
#>     microstate
#> 44       FALSE
#> 45       FALSE
#> 46       FALSE
#> 297      FALSE
#> 298      FALSE
#> 299      FALSE
#> 300      FALSE