Does anyone know how to write an if else statement in R where if the departure delay is more than 15 minutes then the airline has to pay $75 for every minute delayed and if the departure delay is less than 15 minutes then there is no charge?
This is what I wrote but its throwing an error
mutate(Departure Delay charges= if_else(departure_delay>= ’16’|DEP_DELAY<=’15’,75*departure_delay, "0" ))
>Solution :
If you need > 15 mins, then the second dep_delay is not necessary. If true it will multiply departure_delay by 75, it it is FALSE – it will stay 0.
DepartureDelayCharges = ifelse(departure_delay >= 16, 75*departure_delay, 0)