I recently posted a question regarding plotting postions on cities in europe as points on a map. See R, get longitude/latitude data for cities and add it to my dataframe
Here is an alternative way you could handle this.
# METHOD 1: Using geocode() from {ggmap}
library(ggmap)
adr <- adr <- "Agra, New Delhi" # define address
geocode(adr) # get the latitude and longitude
# Information from URL : http://maps.googleapis.com/maps/api/geocode/json?address=Agra,+New+Delhi&sensor=false
# lon lat
1 77.3126 28.54637
# METHOD 2: CODE TO GET THE LATITUDE AND LONGITUDE OF A STREET ADDRESS WITH GOOGLE API
addr <- '6th Main Rd, New Thippasandra, Bengaluru, Karnataka' # set your address here
url = paste('http://maps.google.com/maps/api/geocode/xml?address=', addr,'&sensor=false',sep='') # construct the URL
doc = xmlTreeParse(url)
root = xmlRoot(doc)
lat = xmlValue(root[['result']][['geometry']][['location']][['lat']])
long = xmlValue(root[['result']][['geometry']][['location']][['lng']])
lat
[1] "12.9725020"
long
[1] "77.6510688"