I have
data = {{817, 501}, {818, 549}, {819, 562}, {820, 534}, {821, 534}, {822, 535}, {823, 516}};
How to find argument "822" for 535 (which is the highest in given range) setting range of maximum to 820-823?
SortBy[Select[data, 820 <= #[[1]] <= 823 &], #[[2]] &][[-1, 1]]
Another possibility
MaximalBy[Select[data, 820 <= First[#] <= 823 &], Last]
(* {{822, 535}} *)
data =
{{817, 501}, {818, 549}, {819, 562}, {820, 534}, {821, 534}, {822, 535}, {823, 516}};
r = Between[{820, 823}];
1.
First @ First @ TakeLargestBy[Last, 1] @ Cases[data, {a_, _} /; r @ a]
822
2.
First @ Keys @ TakeLargest[1] @ KeySelect[r] @ MapApply[Rule, data]
822
data = {{817, 501}, {818, 549}, {819, 562}, {820, 534},
{821, 534}, {822, 535}, {823, 516}};
Using GroupBy
:
GroupBy[data, 820 <= First[#] <= 823 &, Last@SortBy[#, Last] &][True]
(*{{822, 535}}*)