I want to do something similar to an INDEX/MATCH in Excel, where the last argument in MATCH is flexible enough to return the index of a value less than or greater than the lookup value by using -1 or 1 instead of 0 for exact match. For example my data column is (100, 150, 275) and the table I want to pull from has (100, 200, 300, 400).
I want to create a column where for each of 100, 150, and 275 the output gives the largest value below each input when there is no exact match. So in this case I want the contents of the new column to be (100, 100, 200).
I also want to create a similar case for the smallest value about each input but I believe the solution will be easy to derive from the first problem. In that case the output I'm looking for would be (100, 200, 300).
I know the logic of what I want to do and can easily do it several different ways in Excel but in R I keep getting the error: "longer object length is not a multiple of shorter object length"
where everything I try keeps referring to the entire vector of what I want to lookup instead of applying the function to each individual element of the column.