I got a df such as this
structure(list(id = c(4375, 4375, 4375, 4375), time = c(0, 88,
96, 114)), class = "data.frame", row.names = c(NA, -4L))
and a second df (df2) such as this
structure(list(id2 = c(4375, 4375, 4375, 4375, 4375, 4375, 4375,
4375, 4375, 4375), time2 = c(0, 2, 87, 88, 94, 97, 101, 104,
109, 114), score2 = c(0.028, 0.057, 0.057, 0.057, 0.057, 0.057,
0.057, 0.085, 0.085, 0.085)), class = "data.frame", row.names = c(NA,
-10L))
I want for each id, to map the time column in both df and creating a score column in df1 and assigning the value of score from df2, when the time value in df1 is equal or less than the time in df2. I want the final df to look like this
structure(list(id3 = c(4375, 4375, 4375, 4375), time3 = c(0,
88, 96, 116), score3 = c(0.028, 0.057, 0.057, 0.085)), class = "data.frame", row.names = c(NA,
-4L))