Description Usage Arguments Value See Also Examples
IP2Location provides proprietary databases for IP geolocation;
this function acts as a binding to them, letting you efficiently geolocate
a vector of IP addresses to retrieve various values (much like maxmind
).
Note that depending on the database type you have, certain fields may or may not be
available.
1 2 3 4 5 6 | ip2location(
ips,
file,
fields = c("country_code", "country_name"),
use_memory = TRUE
)
|
ips |
A character vector of IP addresses. |
file |
The path to an IP2Location binary database. One is included in the package (see the examples below); full datasets can be purchased, and sample ones downloaded, at the ip2location website. |
fields |
Which pieces of metadata to retrieve for each IP address. Options are:
Note that these fields may or may not be available depending on your database type. |
use_memory |
Whether to cache the binary in memory or not. Caching it drastically increases the speed of geolocation, but may be too much for very old machines. Set to TRUE by default. |
A data.frame containing the geolocation metadata about ips
; missing
values are represented by NA
.
maxmind
, which uses MaxMind proprietary databases to get similar
information.
1 2 3 4 | file <- system.file("extdata","ip2_sample.bin", package = "rgeolocate")
example_ip <- "2A04:0000:0000:0000:0000:0000:0000:0000"
ip2location(example_ip, file, c("country_code", "country_name", "region", "city"))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.