I have two data frames that look like something like the following:
df1 <- data.frame(time=seq(0.0, by = 0.003, length.out = 1000))
time
1 0.000
2 0.003
3 0.006
4 0.009
5 0.012
6 0.015
...
df2 <- data.frame(onset=c(0.0, 0.8, 1.9, 2.4), offset=c(0.799, 1.899, 2.399, 3.0))
onset offset A B
1 0.0 0.799 ... ...
2 0.8 1.899 ... ...
3 1.9 2.399 ... ...
4 2.4 3.000 ... ...
In reality there are more columns in each of the data frames, and there are many more times in the first data frame and they're not regularly spaced; there aren't too many more rows in the second data frame. I want to merge the two data frames such that each row in the first data frame gets the extra columns for the appropriate range from the second data frame, and I want to do it efficiently because there are hundreds of thousands of rows involved.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…