Description Usage Arguments Value Examples
ip_in_any
checks whether a vector of IP addresses
fall within any of the speficied ranges.
1 | ip_in_any(ip_addresses, ranges)
|
ip_addresses |
character vector of IP addresses |
ranges |
character vector of CIDR reanges |
a logical vector of whether a given IP was in any of the ranges
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | ## Not run:
north_america <- unlist(country_ranges(countries=c("US", "CA", "MX")))
germany <- unlist(country_ranges("DE"))
set.seed(1492)
targets <- ip_random(1000)
for_sure <- range_generate(sample(north_america, 1))
all(ip_in_any(for_sure, north_america)) # shld be TRUE
## [1] TRUE
absolutely_not <- range_generate(sample(germany, 1))
any(ip_in_any(absolutely_not, north_america)) # shld be FALSE
## [1] FALSE
who_knows_na <- ip_in_any(targets, north_america)
who_knows_de <- ip_in_any(targets, germany)
sum(who_knows_na)
## [1] 464
sum(who_knows_de)
## [1] 43
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.