Created
June 19, 2016 08:33
-
-
Save russch/9ffe24f60dd696b79d2d65924b46347d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
freegeoip <- function(ip, format = ifelse(length(ip)==1,'list','dataframe')) | |
{ | |
if (1 == length(ip)) | |
{ | |
# a single IP address | |
require(rjson) | |
url <- paste(c("http://freegeoip.net/json/", ip), collapse='') | |
ret <- fromJSON(readLines(url, warn=FALSE)) | |
ret <- data.frame(t(unlist(ret))) | |
latlon <- paste(ret$latitude,ret$longitude,sep=",") | |
return(latlon) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment