Introduction

San Francisco International Airport (IATA: SFO, ICAO: KSFO, FAA LID: SFO) is an international airport near San Bruno and Millbrae in unincorporated San Mateo County. It is 13 miles (21 km) south of downtown San Francisco, California,[4] It has flights to points throughout North America and is a major gateway to Europe and Asia.

SFO is the largest airport in the Bay Area and the second busiest in California, after LAX. In 2017, it was the seventh-busiest airport in the United States and the 24th-busiest in the world by passenger count.[5] It is the fifth-largest hub for United Airlines and functions as United’s primary transpacific gateway. It also serves as a secondary hub for Alaska Airlines. It is a major maintenance hub for United Airlines, and houses the Louis A. Turpen Aviation Museum and Library.

The airport is owned and operated by the City and County of San Francisco, despite it being located in San Mateo County. Between 1999 and 2004, the San Francisco Airport Commission operated city-owned SFO Enterprises, Inc., to oversee its business purchases and operations of ventures.
Source:- http://www.wikipedia.com
First Lets Load the Data

Data Source:- https://catalog.data.gov/dataset/air-traffic-landings-statistics

#Load Data As File 
SFO_Airport_data_load<-read.csv(file=file.choose(), header=TRUE, stringsAsFactors=FALSE,strip.white=TRUE, sep=",")
#Convert to Table
SFO_Airport_data <- as.data.table(SFO_Airport_data_load)
#View Data in HTML Format
kable(head(SFO_Airport_data, n = 10), format = 'html') %>%
  kable_styling(bootstrap_options = c('striped', 'hover'))
Activity.Period Operating.Airline Operating.Airline.IATA.Code Published.Airline Published.Airline.IATA.Code GEO.Summary GEO.Region Landing.Aircraft.Type Aircraft.Body.Type Aircraft.Manufacturer Aircraft.Model Aircraft.Version Landing.Count Total.Landed.Weight
200507 ABX Air GB ABX Air GB Domestic US Freighter Narrow Body McDonnell Douglas DC-9 30 40 4066000
200507 ABX Air GB ABX Air GB Domestic US Freighter Narrow Body McDonnell Douglas DC-9 41 1 102000
200507 ATA Airlines TZ ATA Airlines TZ Domestic US Passenger Narrow Body Boeing 757 200 2 396000
200507 ATA Airlines TZ ATA Airlines TZ Domestic US Passenger Narrow Body Boeing 757 300 167 37408000
200507 Air Canada AC Air Canada AC International Canada Passenger Wide Body Boeing 767 333 1 320000
200507 Air Canada AC Air Canada AC International Canada Passenger Narrow Body Airbus A319 114 160 21520000
200507 Air Canada AC Air Canada AC International Canada Passenger Narrow Body Airbus A320 211 146 20761200
200507 Air Canada AC Air Canada AC International Canada Passenger Narrow Body Airbus A321 211 2 343040
200507 Air China CA Air China CA International Asia Passenger Wide Body Boeing 747 400 23 14490000
200507 Air France AF Air France AF International Europe Passenger Wide Body Boeing 747 400 31 18855500


Lets Look how much the data is complete

# View Missing Data
missmap(SFO_Airport_data)


Data Looks quite Clean, now We need to keep only this year data, That means we safely discard anydata that that is less than 201901.
Lets discard the data and View it again(first 20 records)

# Subsettig  Data(Dont Worry, I have USe DYPLR Below) for 2019 Landings only
SFO_Airport_data <- subset(x = SFO_Airport_data, SFO_Airport_data$Activity.Period >= '201901')
# View Data as a table
kable(head(SFO_Airport_data, n=20), format = 'html') %>%
  kable_styling(bootstrap_options = c('striped', 'hover'))
Activity.Period Operating.Airline Operating.Airline.IATA.Code Published.Airline Published.Airline.IATA.Code GEO.Summary GEO.Region Landing.Aircraft.Type Aircraft.Body.Type Aircraft.Manufacturer Aircraft.Model Aircraft.Version Landing.Count Total.Landed.Weight
201901 ABC Aerolineas S.A. de C.V. dba Interjet 4O ABC Aerolineas S.A. de C.V. dba Interjet 4O International Mexico Passenger Narrow Body Airbus A320
51 7266648
201901 Aer Lingus EI Aer Lingus EI International Europe Passenger Wide Body Airbus A332
15 5956889
201901 Aer Lingus EI Aer Lingus EI International Europe Passenger Wide Body Airbus A333
16 6525680
201901 Aeromexico AM Aeromexico AM International Mexico Passenger Narrow Body Boeing B738
93 13417300
201901 Air Canada AC Air Canada AC International Canada Passenger Narrow Body Airbus A319
14 1882748
201901 Air Canada AC Air Canada AC International Canada Passenger Narrow Body Airbus A320
77 10949246
201901 Air Canada AC Air Canada AC International Canada Passenger Narrow Body Airbus A321
6 1029120
201901 Air Canada AC Air Canada AC International Canada Passenger Narrow Body Boeing B738
82 12529600
201901 Air Canada AC Air Canada AC International Canada Passenger Wide Body Boeing B763
2 639800
201901 Air Canada AC Air Canada AC International Canada Passenger Wide Body Boeing B772
1 492000
201901 Air Canada AC Air Canada AC International Canada Passenger Wide Body Boeing B788
19 7220000
201901 Air Canada AC Air Canada AC International Canada Passenger Wide Body Boeing B789
38 16150000
201901 Air China CA Air China CA International Asia Passenger Wide Body Boeing B748
31 21328000
201901 Air France AF Air France AF International Europe Passenger Wide Body Boeing B773
31 17174000
201901 Air India Limited AI Air India Limited AI International Asia Passenger Wide Body Boeing B772
38 18696000
201901 Air India Limited AI Air India Limited AI International Asia Passenger Wide Body Boeing B773
1 554000
201901 Air New Zealand NZ Air New Zealand NZ International Australia / Oceania Passenger Wide Body Boeing B772
1 470000
201901 Air New Zealand NZ Air New Zealand NZ International Australia / Oceania Passenger Wide Body Boeing B773
29 16066000
201901 Air Pacific Limited dba Fiji Airways FJ Air Pacific Limited dba Fiji Airways FJ International Australia / Oceania Passenger Wide Body Airbus A332
12 4766393
201901 Alaska Airlines AS Alaska Airlines AS Domestic US Passenger Narrow Body Airbus A319
176 24250688

Did We Knew This!!!.

We Know that SFO airport is the gateway to Silion Valley, But It is amazing to see that so many Cargo Flights Touches SFO Airport, I wonder, the revenue that can be generated for SFO Airport if these cargo Flights can land in Nearby Airports where landing slots cost less.
SFO_Airport_data$Landing.Count <- as.numeric(SFO_Airport_data$Landing.Count)

#Get Cargo Data (Dont Worry, I have USe DYPLR Below) 
SFO_cargo <- aggregate(SFO_Airport_data$Landing.Count,   by=list(Landing.Aircraft.Type=SFO_Airport_data$Landing.Aircraft.Type), FUN=sum)

#Change the Column Names
colnames(SFO_cargo) <- c("Landing Aircraft Type", "Count")

#View HTML Data Table
kable(head(SFO_cargo, n=5), format = 'html') %>%
  kable_styling(bootstrap_options = c('striped', 'hover'))
Landing Aircraft Type Count
Freighter 1012
Passenger 102042


Landing Density Distribution of SFO Airport.

This Information Can be used to Determine the how many Landings in Total takes place in SFO

#Set options  
options(repr.plot.width = 8, repr.plot.height = 4, repr.plot.res = 5000) #Setting plot size
# get Landing Distribution  
SFO_Airport_data%>%
    ggplot(aes(Landing.Count, fill=..count..))+
    geom_bar(stat = "density")+
    ggtitle("Landing Distribution in SFO Airport")+
    xlab('Number of Landing Distribution Per month')+
    ylab('Number of Landings')


Count of Different Type of Aircraft Landings in SFO(Aircraft Manufacturer).

Clearly Airlines Fly More Boeing than Airbus Aircrafts, by almost 1.5 times

# Convert Landing Count as a Numeric   
SFO_Airport_data$Landing.Count <- as.numeric(SFO_Airport_data$Landing.Count)

# Agreegate All Landing Data per Aircraft Manufacturer
  SFO_Aircrafttypes <- aggregate(SFO_Airport_data$Landing.Count,   by=list(Aircraft.Manufacturer=SFO_Airport_data$Aircraft.Manufacturer), FUN=sum)
  
# Get Color Pallet for random Color Generation
color = grDevices::colors()[grep('gr(a|e)y', grDevices::colors(), invert = T)]
barplot(SFO_Aircrafttypes$x, main="Top 10 timezones",
  xlab="Aircraft Carrier", ylab = "Number of Landings",ylim=c(0,50000),col=sample(color, nrow(SFO_Aircrafttypes)),
  legend = SFO_Aircrafttypes$Aircraft.Manufacturer, beside=TRUE)


Number of Wide Body vs Narrow Body Aircraft Landing in SFO.Per Year(Ignoring Regional Jet and Turbo Prop’s)

From this Graph, We can figure out that number of Narrow Body Aircraft landing is increasing, This explains that the concept of Hub-Spoke Model is being replaced by point-point Flights Served by Narrow Body Aircraft.

# Get All Details of Landings
SFO_Airport_All <- data.frame(SFO_Airport_data_load)
# Create a Variable with Year of Landings
SFO_Airport_All$year=substr(SFO_Airport_All$Activity.Period, 1, 4)
SFO_Airport_All$Landing.Count <- as.numeric(SFO_Airport_All$Landing.Count)
SFO_Airport_All$year <- as.numeric(SFO_Airport_All$year)

# Here I use the DYPLR to Consolidate on Aircraft Body Type
SFO_aircraft_body_type_per_Year <- SFO_Airport_All%>%
    group_by(year,Aircraft.Body.Type)%>%
    summarise(sum_landing = sum(Landing.Count))

# Set Column Names
colnames(SFO_aircraft_body_type_per_Year) <- c("year", "Aircraft_Body_Type", "sum_landing")

# GGPLOT
ggplot(SFO_aircraft_body_type_per_Year, aes(fill=Aircraft_Body_Type, y=sum_landing, x=year)) + 
    geom_bar(position="dodge", stat="identity") +
  theme(legend.position = 'bottom', axis.text.x=element_text(angle=45, hjust=1, size = 15),)+
    ggtitle("Landing of Varous Body Types") +
    xlab("Year on Year Landings")+
    ylab("Number of Landings") 


Top 10 Aircraft Landings in SFO Airport for Year 2019

From this Graph, We can figure out that number of Narrow Body Aircraft landing is higher, This explains that the concept single Isle 737/A320 Family(with A319)dominates the Sky Above SFO Airport. 737 and A320 the single Aisle Workhorse for Airlines Operating into SFO Airport

# Using DYPLR to:-
# Filter Only Boeing & Airbus Aircraft(As Other are two small in Number)
# Then -> get the total of all Aircraft Model
SFO_aircraft_type <- SFO_Airport_All%>%filter(Aircraft.Manufacturer == "Boeing" | Aircraft.Manufacturer == "Airbus")%>%group_by(Aircraft.Model)%>%
    summarise(sum_landing = sum(Landing.Count))%>%arrange(desc(sum_landing))%>%top_n(10)
# GGPLOT 
ggplot(SFO_aircraft_type, aes(fill=Aircraft.Model, y=sum_landing, x=Aircraft.Model)) + 
    geom_bar(position="dodge", stat="identity") +
  theme(legend.position = 'bottom', axis.text.x=element_text(angle=45, hjust=1, size = 15))+
    ggtitle("Aircraft Type for top 10 Landings") +
    xlab("Aircraft Type")+
    ylab("Number of Landings")