In my df, I define c('apple', 'banana') and c('banana', 'apple') are the same, casue the fruit type is the same just the arrangement is different.
Then, How can I remove row No.1 and row No.2 and only keep the last row(wanted_df).
df = data.frame(fruit1 = c('apple', 'banana', 'fig'),
                fruit2 = c('banana', 'apple', 'cherry'))
df
wanted_df = df[3,]
Any help will be high appreciated!
============================
Something wrong with my real data.
The frames2 loses rows which lag = 2.
I wanted data frame shold like wanted_frames.
pollution1 = c('pm2.5', 'pm10', 'so2', 'no2', 'o3', 'co')
pollution2 = c('pm2.5', 'pm10', 'so2', 'no2', 'o3', 'co') 
dis = 'n'
lag = 1:2
frames = expand.grid(pollution1 = pollution1, 
                     pollution2 = pollution2,
                     dis = dis, 
                     lag = lag) %>% 
  mutate(pollution1 = as.character(pollution1),
         pollution2 = as.character(pollution2), 
         dis = as.character(dis)) %>% 
  as_tibble() %>% 
  filter(pollution1 != pollution2)
vec<- with(frames, paste(pmin(pollution1, pollution2), pmax(pollution1, pollution2)))
frames2 = frames[!duplicated(vec), ]
wanted_frames = frames2 %>% mutate(lag = 2) %>% bind_rows(frames2)
 
     
     
    