Building on R - Fastest way to find nearest value in vector, I am interested in getting the nearest value in a vector prior to a specific value.
The DescTools package Closest does not differentiate according to direction.
Eg.
x=c(1,7:10)
min(DescTools::Closest(x, 6, which = F, na.rm = FALSE))
would return 7, while I want 1. Anyone?