This? (df
is your data frame)
merge(df,aggregate(tradeofgdp~country,df,max))
# country tradeofgdp year
# 1 Algeria 0.9 1993
# 2 China 0.5 1990
# 3 Egypt 0.8 2002
If the maximum for a country occurs in multiple years, you will get multiple records for that country.