There are a lot of things wrong.
Firstly, you have changed the latitude and longitude. All locations in your dataset, as indicated, are in Antarctica.
Secondly, revgeocode(...) expects a numerical vector of length 2 containing longitude and latitude in that order. You are passing a data.frame object (this is the cause of the error) and in accordance with (1) in the wrong order.
Thirdly, revgeocode(...) uses google api maps, which limits 2500 requests per day. Therefore, if you really have a large dataset, good luck with that.
This code works with your sample:
data <- read.csv(text="ID, Longitude, Latitude 311175, 41.298437, -72.929179 292058, 41.936943, -87.669838 12979, 37.580956, -77.471439") library(ggmap) result <- do.call(rbind, lapply(1:nrow(data), function(i)revgeocode(as.numeric(data[i,3:2])))) data <- cbind(data,result) data # ID Longitude Latitude result # 1 311175 41.29844 -72.92918 16 Church Street South, New Haven, CT 06519, USA # 2 292058 41.93694 -87.66984 1632 West Nelson Street, Chicago, IL 60657, USA # 3 12979 37.58096 -77.47144 2077-2199 Seddon Way, Richmond, VA 23230, USA
This extracts zipcodes:
library(stringr) data$zipcode <- substr(str_extract(data$result," [0-9]{5}, .+"),2,6) data[,-4]