Data Preparation

This project uses an airline traffic dataset containing passenger, freight, mail, route-distance, carrier, origin, destination, and month information. The data are imported from the public GitHub repository.

data_url <- paste0(
  "https://raw.githubusercontent.com/BIKASHBHOWMIK15/Data-606/main/Project/flights_data_clean.csv")

flights_raw <- read_csv(data_url, show_col_types = FALSE)

# Review the imported dataset.
dim(flights_raw)
## [1] 32476    16
names(flights_raw)
##  [1] "passengers"          "freight"             "mail"               
##  [4] "distance"            "unique_carrier"      "unique_carrier_name"
##  [7] "origin_city_name"    "dest_city_name"      "month"              
## [10] "distance_group"      "class"               "distance_cat"       
## [13] "carrier_type"        "month_name"          "route"              
## [16] "distance_simple"
glimpse(flights_raw)
## Rows: 32,476
## Columns: 16
## $ passengers          <dbl> 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20…
## $ freight             <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,…
## $ mail                <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,…
## $ distance            <dbl> 54, 59, 64, 73, 76, 79, 84, 90, 92, 93, 95, 98, 98…
## $ unique_carrier      <chr> "C5", "M5", "J5", "C5", "6F", "8V", "9X", "6F", "6…
## $ unique_carrier_name <chr> "CommuteAir LLC dba CommuteAir", "Kenmore Air Harb…
## $ origin_city_name    <chr> "Mission/McAllen/Edinburg, TX", "Lopez Island, WA"…
## $ dest_city_name      <chr> "Brownsville, TX", "Kenmore, WA", "Juneau, AK", "D…
## $ month               <dbl> 1, 6, 5, 3, 3, 6, 7, 1, 4, 1, 2, 5, 6, 2, 2, 2, 2,…
## $ distance_group      <dbl> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,…
## $ class               <chr> "F", "F", "L", "F", "L", "F", "F", "L", "L", "L", …
## $ distance_cat        <chr> "less than 500 miles", "less than 500 miles", "les…
## $ carrier_type        <chr> "national carriers", "regional carriers", "regiona…
## $ month_name          <chr> "jan", "jun", "may", "mar", "mar", "jun", "jul", "…
## $ route               <chr> "MFE - BRO", "LPS - KEH", "ELV - JNU", "COS - DEN"…
## $ distance_simple     <chr> "short (<1000 mi)", "short (<1000 mi)", "short (<1…

The supplied CSV includes passengers, freight, mail, distance, unique_carrier, unique_carrier_name, origin_city_name, dest_city_name, month, distance_group, class, distance_cat, carrier_type, month_name, route, and distance_simple.

The following code uses the actual column names in the CSV. The dataset contains passenger counts ranging from 20 to 1,000. No zero-passenger records are present in the current cleaned dataset.

required_variables <- c(
  "passengers", "distance", "unique_carrier",
  "unique_carrier_name", "origin_city_name",
  "dest_city_name", "month", "carrier_type",
  "month_name", "route"
)

missing_variables <- setdiff(required_variables, names(flights_raw))

if (length(missing_variables) > 0) {
  stop(
    "Expected columns not found: ",
    paste(missing_variables, collapse = ", "),
    ". Check the CSV column names before continuing."
  )
}

flights <- flights_raw |>
  mutate(
    passengers = as.numeric(passengers),
    distance = as.numeric(distance),
    month = as.integer(month),
    carrier_type = as.factor(carrier_type),
    month_name = factor(
      tolower(month_name),
      levels = c("jan", "feb", "mar", "apr", "may", "jun", "jul")
    )
  ) |>
  filter(
    !is.na(passengers),
    !is.na(distance),
    !is.na(carrier_type),
    !is.na(month),
    passengers >= 0,
    distance > 0
  )

sample_counts <- tibble(
  Dataset = c("Imported dataset", "Analysis dataset"),
  Number_of_records = c(nrow(flights_raw), nrow(flights))
)

kable(
  sample_counts,
  caption = "Number of records before and after basic cleaning"
)
Number of records before and after basic cleaning
Dataset Number_of_records
Imported dataset 32476
Analysis dataset 32476

The basic cleaning removes records with missing values in the primary analysis variables, negative passenger counts, or nonpositive route distances. All records meeting these criteria are retained. The repository describes the data as covering January through July 2026; the supplied CSV does not include a year column, so the study period is based on the repository description rather than a year filter in R.

summary(flights[c("passengers", "distance", "month")])
##    passengers        distance          month      
##  Min.   :  20.0   Min.   :  50.0   Min.   :1.000  
##  1st Qu.:  59.0   1st Qu.: 350.0   1st Qu.:2.000  
##  Median : 142.0   Median : 672.0   Median :4.000  
##  Mean   : 271.3   Mean   : 820.1   Mean   :3.919  
##  3rd Qu.: 412.0   3rd Qu.:1114.0   3rd Qu.:6.000  
##  Max.   :1000.0   Max.   :5071.0   Max.   :7.000
table(flights$carrier_type, useNA = "ifany")
## 
##    major carriers national carriers regional carriers 
##             19811              7282              5383
table(flights$month_name, useNA = "ifany")
## 
##  jan  feb  mar  apr  may  jun  jul 
## 4991 4573 4907 4407 4792 4811 3995
range(flights$month, na.rm = TRUE)
## [1] 1 7

Research question

Is route distance associated with passenger traffic across U.S. airline reporting records during January through July 2026?

The project will examine whether airline reporting records for longer routes tend to have higher or lower reported passenger counts. The question focuses on an association and does not assume that route distance causes passenger traffic to change.

Research Hypotheses

The project will investigate whether airline route distance is statistically associated with reported passenger traffic.

Null Hypothesis (H0):

There is no statistically significant linear association between airline route distance and reported passenger traffic across the airline reporting records.

\[ H_0: \rho = 0 \]

Alternative Hypothesis (HA):

There is a statistically significant linear association between airline route distance and reported passenger traffic across the airline reporting records.

\[ H_A: \rho \neq 0 \]

The hypotheses will be evaluated using Pearson correlation and simple linear regression, provided the data and model assumptions are reasonably appropriate. A significance level of 0.05 will be used. If the assumptions for Pearson correlation are not appropriate, Spearman rank correlation may be considered as an alternative.

The analysis will examine association rather than causation.

Cases

Each case represents an airline reporting record for a carrier and a route during a reporting period. A case should not be interpreted as one individual aircraft departure.

  • Original imported dataset: 32,476 records.
  • Analysis dataset after the basic cleaning steps: 32,476 records.
  • Study period, according to the repository description: January–July 2026.

Data collection

This project uses secondary data made available in a public GitHub repository. The dataset contains reported airline traffic information, including passenger counts, freight and mail quantities, route distances, carrier identifiers, origin and destination cities, and reporting months.

The data were collected and made available before this project. The researcher does not assign airlines to routes, manipulate route distances, or collect information directly from passengers.

The cleaned dataset used in this analysis is publicly available in the researcher’s GitHub repository (Bhowmik, 2026).

Type of study

This is an observational study. The project analyzes existing airline reporting records and does not involve an experiment or treatment assignment. Therefore, the results can describe associations in the dataset but cannot establish cause and effect.

Data Source

The cleaned airline traffic dataset used in this project is maintained in the researcher’s public GitHub repository (Bhowmik, 2026). The repository contains the CSV file used for data preparation, exploratory analysis, and statistical modeling.

The dataset includes airline reporting information such as passenger counts, freight, mail, route distance, carrier identification, origin and destination cities, and reporting months.

The dataset can be accessed through the following links:

Dataset and Source Code

The analysis uses the cleaned CSV file available in the repository. The repository is the source of the version analyzed in this project; it should not be confused with the original organization that collected the airline reporting data.

Response

The response variable is passengers.

  • Type: Quantitative (numerical).
  • Description: The reported passenger count for an airline reporting record.

Explanatory

The primary explanatory variable is distance.

  • Type: Quantitative (numerical).
  • Description: The reported distance of the airline route.

Additional explanatory or grouping variables for exploratory analysis include:

  • carrier_type — categorical; carrier classification supplied in the dataset (for example, regional carriers and national carriers).
  • month_name — categorical; reporting month from January through July.
  • unique_carrier — categorical; airline carrier identifier.
  • route — categorical; origin-destination route.

The primary analysis will examine the relationship between distance and passengers. Carrier type and month will be used for additional descriptive comparisons.

Relevant summary statistics

The following summaries describe passenger traffic and route distance in the analysis dataset. Mean, standard deviation, median, and interquartile range are included because passenger counts may be skewed.

Overall descriptive statistics

overall_summary <- psych::describe(
  flights |>
    select(passengers, distance)
)

kable(
  round(overall_summary, 2),
  caption = "Descriptive statistics for passenger count and route distance"
)
Descriptive statistics for passenger count and route distance
vars n mean sd median trimmed mad min max range skew kurtosis se
passengers 1 32476 271.28 281.88 142 223.76 149.74 20 1000 980 1.19 0.12 1.56
distance 2 32476 820.09 621.16 672 738.16 545.60 50 5071 5021 1.31 2.44 3.45

Passenger traffic by carrier type

carrier_summary <- flights |>
  group_by(carrier_type) |>
  summarise(
    n = n(),
    mean_passengers = mean(passengers, na.rm = TRUE),
    sd_passengers = sd(passengers, na.rm = TRUE),
    median_passengers = median(passengers, na.rm = TRUE),
    IQR_passengers = IQR(passengers, na.rm = TRUE),
    .groups = "drop"
  )

kable(
  carrier_summary,
  digits = 2,
  caption = "Passenger traffic summary by carrier type"
)
Passenger traffic summary by carrier type
carrier_type n mean_passengers sd_passengers median_passengers IQR_passengers
major carriers 19811 256.06 270.98 135 310.0
national carriers 7282 364.45 328.50 219 611.0
regional carriers 5383 201.27 213.74 112 231.5

Passenger traffic by month

monthly_summary <- flights |>
  group_by(month_name) |>
  summarise(
    n = n(),
    mean_passengers = mean(passengers, na.rm = TRUE),
    sd_passengers = sd(passengers, na.rm = TRUE),
    median_passengers = median(passengers, na.rm = TRUE),
    .groups = "drop"
  )

kable(
  monthly_summary,
  digits = 2,
  caption = "Passenger traffic summary by month"
)
Passenger traffic summary by month
month_name n mean_passengers sd_passengers median_passengers
jan 4991 287.86 286.90 165
feb 4573 297.89 304.99 143
mar 4907 236.72 261.94 114
apr 4407 261.57 279.29 139
may 4792 279.21 277.55 160
jun 4811 274.42 279.22 150
jul 3995 260.02 277.83 139

Distribution of passenger traffic

ggplot(flights, aes(x = passengers)) +
  geom_histogram(bins = 30, color = "white") +
  labs(
    title = "Distribution of Reported Passenger Traffic",
    x = "Reported passenger count",
    y = "Number of reporting records"
  ) +
  theme_minimal()

Passenger counts may have a right-skewed distribution. The following plot uses a logarithmic horizontal scale and excludes zero values from the visualization only; zero-passenger records remain in the analysis dataset.

ggplot(
  flights |> filter(passengers > 0),
  aes(x = passengers)
) +
  geom_histogram(bins = 30, color = "white") +
  scale_x_log10() +
  labs(
    title = "Distribution of Positive Passenger Counts",
    subtitle = "Horizontal axis uses a logarithmic scale",
    x = "Reported passenger count (log scale)",
    y = "Number of reporting records"
  ) +
  theme_minimal()

Distribution of route distance

ggplot(flights, aes(x = distance)) +
  geom_histogram(bins = 30, color = "white") +
  labs(
    title = "Distribution of Route Distance",
    x = "Route distance",
    y = "Number of reporting records"
  ) +
  theme_minimal()

Relationship between route distance and passenger traffic

ggplot(flights, aes(x = distance, y = passengers)) +
  geom_point(alpha = 0.25) +
  geom_smooth(method = "lm", se = TRUE) +
  labs(
    title = "Route Distance and Reported Passenger Traffic",
    x = "Route distance",
    y = "Reported passenger count",
    caption = "The fitted line describes an overall linear trend; it does not establish causation."
  ) +
  theme_minimal()

Preliminary analysis plan

The analysis will begin with descriptive statistics and visualizations to examine the distributions of passenger counts and route distances and the pattern between the two variables. Pearson correlation and simple linear regression may be considered if the relationship and model assumptions are reasonably appropriate. If the data do not support those methods, Spearman correlation may be considered as an alternative.

The dataset may contain repeated records for the same carrier or route across reporting periods. This structure will be considered when interpreting the results, especially when assessing the independence assumption. Conclusions will be limited to the reporting records represented in this dataset and the January–July 2026 period described by the repository.

The statistical methods will be selected based on the research question, data characteristics, and relevant statistical assumptions.