A vectorised membership predicate built on country_groups().
Arguments
- x
A vector of country names or codes.
- group
A single group name (see
country_groups()).- origin
How to read
x(default"country.name").- as_of
A date or year at which to evaluate membership;
NULL(default) uses the current snapshot. A bare year means 1 January of that year, so use a"YYYY-MM-DD"string when an accession or exit falls mid-year. Seecountry_groups().
Value
A logical vector the same length as x. A value origin cannot
resolve to an ISO code answers FALSE – the same as a country that is
genuinely outside the group – so run check_country_match() first if you
need to tell "not a member" from "not recognised".
Examples
in_group(c("France", "United States", "Japan"), "EU")
#> [1] TRUE FALSE FALSE
# membership is a function of time
in_group("United Kingdom", "EU", as_of = 2016)
#> [1] TRUE
in_group("United Kingdom", "EU", as_of = 2021)
#> [1] FALSE
