Created
February 14, 2016 08:25
-
-
Save sriyoda/6c514e13737afaa043ba to your computer and use it in GitHub Desktop.
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
pop <- read.csv("pop_tots.csv", stringsAsFactors = F) | |
pop <- melt(pop, id=c("Country.Name","Country")) #transforms 1970-2015 columns to year variable | |
str_sub(pop$variable, 1,1) <- '' #remove appended character added to all rows when transforming | |
passenger <- read.csv("passenger_tots.csv", stringsAsFactors = F) | |
passenger <- melt(passenger, id=c("Country.Name","Country")) #transforms 1970-2015 columns to year variable | |
str_sub(passenger$variable, 1,1) <- '' #remove appended character added to all rows when transforming | |
gdp <- read.csv("gdp_totals.csv", stringsAsFactors = F) | |
gdp <- melt(gdp, id=c("Country.Name","Country")) #transforms 1970-2015 columns to year variable | |
str_sub(gdp$variable, 1,1) <- '' #remove appended character added to all rows when transforming | |
country <- inner_join(pop,passenger, by = c("Country.Name","Country","variable")) #joining population, passenger dataframes | |
country <- inner_join(country,gdp, by = c("Country.Name","Country","variable")) # then joining with gdp | |
names(country) <- c("Country.Name","Country","Year",'Population','Passenger','GDP') #changing column names | |
country_subset$Year<- as.numeric(country_subset$Year) #converting year column to numeric for googlevis |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment