Skip to content

Instantly share code, notes, and snippets.

@sriyoda
Last active February 16, 2016 05:37
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 sriyoda/be1216082c518d2d2343 to your computer and use it in GitHub Desktop.
Save sriyoda/be1216082c518d2d2343 to your computer and use it in GitHub Desktop.
# Showing transformation for 2007 only, this was done 4 times for years 2004-2007
f2007 <- read.csv("2007.csv", stringsAsFactors = F)
f2007 <- f2007[,c(1,2,3,4,9)] #subsetting
f2007$date <- paste(f2007$Year, f2007$Month, f2007$DayofMonth, sep='-') #creating Date Column
f2007_1 <- f2007 %>% group_by(date) %>% summarise(count = n()) #creating a count column of total flights per day
f2007_2 <- f2007 %>% group_by(UniqueCarrier, date) %>% summarise(count = n()) #creating count column of total flights per day by Carrier
flights_by_year <- rbind(f2007_2,f2006_2,f2005_2,f2004_2) #summarising count by carrier
f2007_carrier <- group_by(f2007_2, UniqueCarrier, Month) %>% summarise(count=n()) #summarising count by Carrier
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment