I am currently working with the nycflights13 dataset, specifically focusing on the flights and plans data. Within my analysis, I am using a dataframe called "df_routes", which contains the variables origin, dest, and flights (n()). This data frame is comprised of the routes for the top 50 plans with the most flights, totaling 68 routes.
My current goal is to filter the routes in the flights dataframe, in order to evaluate delays grouped by the same routes. To do so, I am using the following code:
df_delay <- df_flights %>%
filter(origin %in% df_routes$origin & dest %in% df_routes$dest)
However, the filter function is not performing as desired. Specifically, I would like the filter function to check if the origin and destination are the same for the row currently being analysed. This will ensure that only flights with the same route are being evaluated.