==============================

1. Create Flight Data

==============================

flights <- data.frame( FlightID = c(“F101”,“F102”,“F103”,“F104”,“F105”), Airline = c(“Indigo”,“AirIndia”,“SpiceJet”,“Vistara”,“Indigo”), Type = c(“Domestic”,“International”,“Domestic”,“International”,“Domestic”), Passengers = c(180,220,150,200,170), Fare = c(5000,12000,4500,15000,4800), Delay = c(10,55,5,120,20) )

==============================

2. Insert Airport column at 3rd position

==============================

flights <- cbind( flights[,1:2], Airport = “Delhi”, flights[,3:6] )

==============================

3. Sort by Fare (descending)

==============================

sorted_flights <- flights[order(-flights$Fare), ]

==============================

4. Count Domestic vs International

==============================

flight_type_count <- table(flights$Type)

==============================

5. Average Passengers

==============================

avg_passengers <- mean(flights$Passengers)

==============================

6. Insert New Flight Row

==============================

new_flight <- data.frame( FlightID=“F106”, Airline=“AirAsia”, Airport=“Delhi”, Type=“Domestic”, Passengers=160, Fare=5200, Delay=25 )

flights <- rbind(flights, new_flight)

==============================

7. Create DelayCategory column

==============================

flights\(DelayCategory <- ifelse( flights\)Delay < 15, “On Time”, ifelse(flights$Delay <= 60, “Moderate Delay”, “High Delay”) )

==============================

8. Top 2 Flights by Fare

==============================

top2_flights <- flights[order(-flights$Fare), ][1:2, ]

==============================

Outputs

==============================

flights sorted_flights flight_type_count avg_passengers top2_flights