I have a data.frame x with date and Value
x
date
Value
x = structure(list(date = structure(c(1376534700, 1411930800, 1461707400, 1
sapply(y, function(z) x$Value[which.min(abs(x$date - z))]) # [1] 40 65 44 67 44
Using data.table you can join to the nearest value
data.table
library(data.table) x <- as.data.table(x) y <- data.table(date=y) res <- x[y, on='date', roll='nearest']