We have flight data in the package hflights. There is one variable known as
Dest (Destination Airport), I want to know how many flights are traveling to "SFO" or "OAK" destination.
This can be achieved using 3 ways :
#dataset name is hflights
library(hflights)
flights <- tabl_df(hflights)
#1st Approach
dest_flights <- flights %>%
filter(Dest=="SFO"|Dest=="OAK")
#2nd approach
dest_flights <- filter(flights,Dest %in% c("SFO","OAK")
#3rd approach
dest_flights <- flights %>%
filter(Dest==c("SFO","OAK")
1st Approach and 2nd Approach will yield same results but the 3rd approach is giving different output results.
May I know what is the conceptual difference between first two and third approach ?
