Created
August 3, 2016 19:45
-
-
Save sjstebbins/ef67bb834b567d377ee319eaad063ef8 to your computer and use it in GitHub Desktop.
Data merging function for shiny app
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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