I have a vector of numbers
f <- c(1, 3, 5, 8, 10, 12, 19, 27)
I want to compare the values in the vector to another number, and find the c
I think this answer is pretty straightforward:
f <- c(1,3,6,8,10,12,19,27) x <- 18 # find the value that is closest to x maxless <- max(f[f <= x]) # find out which value that is which(f == maxless)