Lookup values corresponding to the closest date

后端 未结 2 1241
时光说笑
时光说笑 2020-12-22 09:05

I have a data.frame x with date and Value

x = structure(list(date = structure(c(1376534700, 1411930800, 1461707400, 
1         


        
2条回答
  •  情歌与酒
    2020-12-22 09:41

    sapply(y, function(z) x$Value[which.min(abs(x$date - z))])
    # [1] 40 65 44 67 44
    

提交回复
热议问题