Learn R Programming

fivethirtyeight (version 0.5.0)

airline_safety: Should Travelers Avoid Flying Airlines That Have Had Crashes in the Past?

Description

The raw data behind the story "Should Travelers Avoid Flying Airlines That Have Had Crashes in the Past?" https://fivethirtyeight.com/features/should-travelers-avoid-flying-airlines-that-have-had-crashes-in-the-past/.

Usage

airline_safety

Arguments

Format

A data frame with 56 rows representing airlines and 9 variables:

airline

airline

incl_reg_subsidiaries

indicates that regional subsidiaries are included

avail_seat_km_per_week

available seat kilometers flown every week

incidents_85_99

Total number of incidents, 1985-1999

fatal_accidents_85_99

Total number of fatal accidents, 1985-1999

fatalities_85_99

Total number of fatalities, 1985-1999

incidents_00_14

Total number of incidents, 2000-2014

fatal_accidents_00_14

Total number of fatal accidents, 2000-2014

fatalities_00_14

Total number of fatalities, 2000-2014

Examples

Run this code
# NOT RUN {
# To convert data frame to tidy data (long) format, run:
library(dplyr)
library(tidyr)
library(stringr)
airline_safety_tidy <- airline_safety %>%
  gather(type, count, -c(airline, incl_reg_subsidiaries, avail_seat_km_per_week)) %>%
  mutate(
    period = str_sub(type, start=-5),
    period = str_replace_all(period, "_", "-"),
    type = str_sub(type, end=-7)
  )
# }

Run the code above in your browser using DataLab