The code below works perfectly fine and outputs the data of interest. However, I am wondering if there is a better solution or different way think about the logic.
Essentially, I need filter for the updated_dt (date time) based on the grouping for only the 717 aircraft and pilots (first part of the code). All the other combination of aircrafts and pilots or flight attendants does not need to change.
Just seems like there should be a smoother process and it looks like there may be many edge cases where I need to apply operations on specific groups (pilors or FAs) per aircrast time.
int_717_p <- int_prob_final_pairing %>%
filter(EQUIPMENT == "717",
CREW_INDICATOR == "P") %>%
group_by(PAIRING_POSITION, PAIRING_NO, DEPARTING_CITY, ARRIVAL_CITY, SCHED_DEPARTURE_DATE, SCHED_DEPARTURE_TIME, PAIRING_DATE) %>%
filter(updated_dt == max(updated_dt))
all_other_carft <- int_prob_final_pairing %>%
filter(!EQUIPMENT == "717")
fa_717 <- int_prob_final_pairing %>%
filter(EQUIPMENT == "717",
CREW_INDICATOR == "FA")
final_pairing <- rbind(int_717_p, all_other_carft, fa_717)