Skip to content

Instantly share code, notes, and snippets.

@sjstebbins
Created August 3, 2016 19:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sjstebbins/ef67bb834b567d377ee319eaad063ef8 to your computer and use it in GitHub Desktop.
Save sjstebbins/ef67bb834b567d377ee319eaad063ef8 to your computer and use it in GitHub Desktop.
Data merging function for shiny app
#set source and destination country latitude and longitudes
ihs <- read.csv("https://raw.githubusercontent.com/sjstebbins/ShinyApp/master/Data/ihs.csv")
countries <- read.delim("https://raw.githubusercontent.com/sjstebbins/ShinyApp/master/Data/countries.csv")
#join tables with new source and destination lat and longs
ihs <- left_join(ihs, select(countries,Country,Latitude,Longitude), by=c('Source..1.' ='Country')) %>%
rename(Source.Country.Lat=Latitude, Source.Country.Long=Longitude)
ihs <- left_join(ihs, select(countries,Country,Latitude,Longitude), by=c('Primary.Destination.Country' ='Country')) %>%
rename(Destination.Country.Lat=Latitude, Destination.Country.Long=Longitude)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment