I have a dataframe that has a list of countries on one column and I am looking to get the Continent Name, Latitude and Longitude of that country.
For example,
df <- data.frame(CountryName = c("Austria", "Czech Republic", "Finland"))
I am looking to get a dataframe that has Continent, latitude and longitude with it.
library(countrycode)
library(geocode)
df$continent <- as.factor(countrycode(sourcevar = df[, "CountryName"], origin = "country.name", destination = "continent"))
So, I have got the Continent in my dataframe now.
geocode("Austria")
returns lat and long in R.
Can you guide me in getting that inside the Dataframe.
Thanks.