I have a frame
J = data.frame(Entry = c(100, 5, 10, 20, 35))
For each record I want to find the nearest value and end up with
Entry | nearest
100 | 35
5 | 10
20 | 10
35 | 20
I looked at the data table code Find closest value in a vector with binary search
but because for Entry
I am trying to find the closest value it just returns the vector that I enter. How can I do this?