I would like to filter 'similar' entries from a list in R. The input list follows:
d1=data.frame(y1 = c('Mike'),
y2 = c('Tsoutsa'),
y3 = c('Apple'),
time = 50)
d2=data.frame(y1 = c('Mike'),
y2 = c('Tsoutsa'),
y3 = c('Orange'),
time = 160)
d3=data.frame(y1 = c('Mike'),
y2 = c('Tsoutsa'),
y3 = c('Lemon'),
time = 100)
d4=data.frame(y1 = c('Anna'),
y2 = c('Pournova'),
y3 = c('Nikolief'),
time = 30)
d5=data.frame(y1 = c('Anna'),
y2 = c('Pournova'),
y3 = c('Leeds'),
y4 = c('York'),
time = 80 )
d6=data.frame(y1 = c('Loulis'),
y2 = c('City'),
time = 200 )
d7=data.frame(y1 = c('Ann'),
y2 = c('Klitor'),
time = 200 )
input = list(d1, d2, d3, d4, d5, d6, d7)
In the output list I would like to keep only the dataframes that have unique y1 and y2 values. If there are dataframes with same y1 and y2 then keep the one with the highest time.
Hence, the output list should be: output = list(d2, d5, d6, d7).
What is the most efficient way of doing this? Much appreciated!