Metric 1

Our first metric to determine if air travel is no longer safe is to visualize the total number of incidents between two 15 year periods to check for an increase

#Metric 1: Comparison of incidents between two time periods
#Create new data frame
Incidents<-data.frame((p<-AS$incidents_85_99),(q<-AS$incidents_00_14))
#Change column names and view data frame
names(Incidents)[1]<-"Incidents from 1985 to 1999"
names(Incidents)[2]<-"Incidents from 2000 to 2014"
#Create bar plot
barplot((colSums(Incidents[1:2])),
        main = "Comparison of Incident Numbers between Periods", 
        xlab="Time Period of Incidents",
        ylab="Number of Incidents",
        col="red")

We can see from the above graph that there are clearly less incidents occurring in the modern period than in the prior period.

Metric 2

Our second metric looks at the number of incidents of airlines during each time period that have have more than 15 incidents. In other words we are determining how many airlines average more than 1 incident per year and how many indcidents they have had. This allows us to see if the incidents are spread out evenly or mostly the result of a small number of airlines. The two graphs let us know if the number of incident prone airlines have increased or decreased between the two periods.

#Metric 2:Determine airlines with more than 15 incidents during period
#Filter data
greaterThan15<-filter(ASedit2,incidents>15,period=="00_14")
#Create bar plot
ggplot(greaterThan15, aes(x=airline, y=incidents,fill=airline)) + 
  geom_bar(stat="identity")+
  ggtitle("Airlines averaging more than one Incident per Year(2000-2014)")+
  ylab("Number of Incidents")+
  xlab("Airline")

#Create filter for older period
greaterThan15old<-filter(ASedit2,incidents>15,period=="85_99")
#Create older period bar plot
ggplot(greaterThan15old, aes(x=airline, y=incidents, fill=airline)) + 
  geom_bar(stat="identity")+
  ggtitle("Airlines averaging more than one Incident per Year(1985-1999)")+
  ylab("Number of Incidents")+
  xlab("Airline")+theme(axis.text.x = element_text(angle = 90))

We can see two very encouraging things in this graph. First, only two airlines in the modern period have avergaed more than 1 incident per year during the period while the prior perio had 6 airlines. Second the airlines in the modern period also had far less incidents as even the most problematic airline comes in at under 25 incidents while the prior period had an airline exceed 70 incidents during the 15 year period.

Metric 3

We already know from Metric 1 that more total incidents occured in the 20th century period than the 21st century period, but this plot will reveal which period had more incidents translate into fatal accidents.

#Metric 3: Visualize how many of each period's incidents were fatal accidents

#create plot of incidents and fatal accidents by period
ggplot(data=ASedit2)+
  geom_point(aes(x=incidents,y=fatal_accidents, col=period))+
  xlab("Number of Incidents")+
  ylab("Number of Fatal Accidents")+
  ggtitle("General Incidents Compared to Fatal Accidents by Period")+
  facet_wrap(~period,nrow=2)

This graphic shows us that not only does the modern period have less total incidents than the prior period, but they also are less likely to have these incidents be fatal.

Metric 4

Metric 4 uses the Airline Safety Network data along with supplemental car traffic data from FARS. The fatality rate is calculated by dividing the absolute fatalities of each travel method by each respective measure of travel equivalents (Available seat miles traveled converted from avaliables seat km per week and vehicle miles travled ). Finally, the calculated fatality rates are visualized to show which travel method experiences more fatalities per travel eqivalents

#Metric 4:Compare fatality rate of cars to fatality rate of air travel

#import supplemental data (FARS)
carStat<-read.csv("us_crash_stats.csv")
#Select columns
carStat<-select(carStat,Year,Fatalities,Vehicle.Miles.Traveled..Billions.,Fatality.Rate.per.100.Million.VMT)
#Filter dataset years
carStat<-filter(carStat,Year>"1999")
AS0014<-filter(ASedit2,period=="00_14")
#convert available seat km/week to available seat miles
convertAsk<-AS0014$avail_seat_km_per_week*(1.609344*7)
#Sum available seat miles
totalAvailableSeatMiles<-sum(convertAsk)
#Sum airline fatalities
totalAirFatalities<-sum(AS0014$fatalities)
#Sum car fatalities
totalCarFatalities<-sum(carStat$Fatalities)
#sum and convert car vehicle miles
totalVehicleMiles<-(sum(carStat$Vehicle.Miles.Traveled..Billions.))*1000000000
#Calculate air fatality rate
airFatality<-totalAirFatalities/totalAvailableSeatMiles
#Calculate car fatality rate
carFatality<-totalCarFatalities/totalVehicleMiles
#Create data frame
fatalityComparison<-data.frame(totalAvailableSeatMiles,
      totalAirFatalities,
      totalCarFatalities,totalVehicleMiles,
      airFatality,carFatality)
#Create bar plot to compare rates
barplot((colSums(fatalityComparison[5:6])),
        main = "Comparision of Fatality rates between Travel Methods", 
        xlab="Fatality Method",
        ylab="Fatality Rate",
        col="light blue")

This graph very certainly shows that even on the basis of travel distance equivalents, air travel is far safer than car travel.

Metric 5

Metric 5 will measure the passenger revenue per available seat mile (PRASM) from 1995 to 2018 to determine if the negative media coverage of air travel over the last decade has taken a significant effect on airlines equating to a lower PRASM compared to earlier years in the visualization (supplemental data set from Airline Data Project)

#Metric 5: Determine if bad publcitiy has significantly impacted airline data

#Load airline revenue data from Airline Data Project
PRASM<-read.csv("System Passenger Revenue per Available Seat Mile (PRASM).csv")
#Filter rows and select columns
PRASM<-filter(PRASM,System.Passenger.Revenue.per.Available.Seat.Mile..PRASM.=="Total All Sectors")
PRASM<-select(PRASM,X.1:X.24)
#Rename columns
colnames(PRASM)<- c("1995","1996","1997","1998","1999","2000","2001",
                    "2002","2003","2004","2005","2006","2007","2008",
                    "2009","2010","2011","2012","2013","2014",
                    "2015","2016","2017","2018")
#Gather data
PRASM<-gather(PRASM, key="Year",value="System.Passenger.Revenue.per.Available.Seat.Mile")
## Warning: attributes are not identical across measure variables;
## they will be dropped
#Plot data
plot(System.Passenger.Revenue.per.Available.Seat.Mile~Year,data=PRASM)

The results of this graph show good news for us as the nonstop negative publicity of the media does not seem to have had a material detrimental impact on revenue stream. Of course the data ends in 2018 and does not take into account the negative impacts of COVID-19.

Metric 6

Our final metric visualizes absolute numbers of fatalities of the two periods from the airline safety data set in the form of the boxplot. This graphic provides a visual representation of the distribution and median that we can use to compare fatalities between the two periods while also taking outlier data into account for the most accurate data represenation

#Metric 6: Visualize and compare absolute fatalties between periods

#create box plot
ggplot(data=ASedit2,mapping = aes(x=period,y=fatalities, fill= period))+ 
  geom_boxplot()+
  ggtitle("Absolute Fatalities by Period")

#filter for modern period
modernPeriodFat<-filter(ASedit2,period=="00_14")
#calculate modern period median
median(modernPeriodFat$fatalities)
## [1] 0
#filter for prior period 
priorPeriodFat<-filter(ASedit2,period=="85_99")
#calculate prior period median
median(priorPeriodFat$fatalities)
## [1] 48.5

With a distribution and median that is far lower, it is clear that flying in the modern period produces less fatalties than the prior period. This shows that in all three safety metrics (Incidents, Fatal Accidents, and Fatalities) flying is safer today than at any point in the past.