r4ds-exercise-solutions
r4ds-exercise-solutions copied to clipboard
Chapter 5 - Exercise 5.2.1 Question 4 (Trick Question/ Possible Mistake)
Hello jrnold, I hope you are well!
In the question 4: "Departed in summer (July, August, and September)"
The solution might be a bit trick... The go to solution is:
filter(flights, month %in% c(7,8,9))
However, it does not consider the fact that a flight might had been schedule for September 30th at 23h59 (military time) and had a delay of 1 or more minutes. Therefore, making the flight departure on October...
A possible way of solving the problem is:
filter(flights, month >= 7, month <= 9, (flight$sched_dep_time + flight$dep_delay) <= 2359)
I am not sure if this is even a real issue (neither if my code really solves the problem Lol), but I wanted to share it anyways. Thank you jrnold and team for providing such amazing info to the community!
Best regards,
EnzoNMigliano