I cannot get rgeolocate to work properly. I need to be able to determine if an IP address is in Australia or not.
I have a list of IP addresses in a csv. However I have provided a sample code below and get the following error:
Error in maxmind_(ips, normalizePath(path.expand(file)), fields) :
Not compatible with STRSXP: [type=list].
I have googled and searched for a solution to this but nothing I have found has worked to date and I would really appreciate it if anyone knew the solution.
The rgeolocate package has successfully downloaded and the GeoLite2-Country.mmdb appears to be where it should be within the extdata folder.
library(rgeolocate)
ip_lst <-
data.frame(
"ip_lst" = c(
"27.33.27.39",
"203.219.204.84",
"203.5.106.68",
"180.150.74.11",
"193.116.238.48",
"1.157.7.35",
"61.69.150.57",
"155.143.204.211"
)
)
file <- system.file("extdata","GeoLite2-Country.mmdb", package = "rgeolocate")
results <- maxmind(ip_lst, file, c("continent_name", "country_code", "country_name"))
results
I have tried multiple versions of the Maxmind code unsuccessfully. Grateful in advance for any help.
You've created a data frame called ip_lst containing one variable called ip_lst
, which is not wrong, but it can be confusing. The problem here is that the maxind
function is expecting a character vector, but you are supplying a data frame. So the following should work:
maxmind(ip_lst$ip_lst, file, c("continent_name", "country_code", "country_name"))
continent_name country_code country_name
1 Oceania AU Australia
2 Oceania AU Australia
3 Oceania AU Australia
4 Oceania AU Australia
5 Europe GB United Kingdom # <-- Not an Aussie 8(
6 Oceania AU Australia
7 Oceania AU Australia
8 Oceania AU Australia