This code shows how to get the coordinates of an address using the google maps API. At the time of running this code (5/22/2021) the google API is free up to a certain amount of requests.
First we load the google maps library and use the key that we obtain through google.
library(ggmap)
register_google(key="yourkey")
We are going to work with a made-up dataframe
df <- data.frame (Address_column = c("Av. Corrientes 1125, Ciudad autónoma de Buenos Aires, Argentina", "Ladislao Martínez 132, Martinez, Buenos Aires, Argentina") )
Now we calculate longitude and latitude with mutate_geocode
df<-mutate_geocode(df, location = Address_column, output = "latlona")
The result in this case will have 4 columns: our original address, lon, lat, and a new address column with the address ggmap found from our input.