Last active
April 29, 2017 01:14
-
-
Save viveknarang/e60be7a397b855f40daadbc7af35ebaa 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
################################################################ | |
##################### Assignment A8-A ########################## | |
####################################### Vivek Narang ########### | |
# Start | |
# Importing libraries | |
library(dplyr) | |
# Reading the csv file | |
airport <- read.csv(file="c:\\A8.csv",head=TRUE,sep=",", stringsAsFactors=FALSE) | |
# Getting distinct id's | |
distinctIDs <- distinct(airport, OriginAirportID) | |
# For each distinct Airport ID | |
for(i in 1:nrow(distinctIDs)) { | |
# Filter rows looking for the airportID | |
filteredRows <- filter(airport, OriginAirportID == distinctIDs[i,1]) | |
# Omit NA's | |
filternom <- na.omit(filteredRows[37]) | |
# Compute and print the min, max and mean for each | |
cat("\nFor The origin Airport", filteredRows[i,15], "(AirportID:",distinctIDs[i,1],",","City:",filteredRows[i,16],")\n"); | |
cat("The Mininum Taxi Out Time is:", min(filternom)," minutes, The Maximum Taxi out time is:",max(filternom)," minutes\n") | |
cat("and the Average Taxi out time is:",colMeans(filternom)," minutes\n") | |
# Break after showing the first six rows | |
if (i == 6) { | |
break; | |
} | |
} | |
# End |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment