I have one data frame (df1) with a timestamp.
Timestamp |
---|
2021-11-09 13:19:42 |
2021-11-09 13:21:00 |
2021-11-09 13:22:25 |
2021-11-09 13:23:00 |
I have another data frame (df2) with start and end timestamps and a value. The start and end range is 2 minutes.
Start | End | Value |
---|---|---|
2021-11-09 13:18:01 | 2021-11-09 13:20:00 | 6 |
2021-11-09 13:20:01 | 2021-11-09 13:22:00 | 9 |
2021-11-09 13:22:01 | 2021-11-09 13:24:00 | 2 |
I want to modify df1 such that if df1$Timestamp falls between a given Start and End interval from df2, the corresponding Value from df2 gets added to a new column in df1.
Timestamp | Value |
---|---|
2021-11-09 13:19:42 | 6 |
2021-11-09 13:21:00 | 9 |
2021-11-09 13:22:25 | 2 |
2021-11-09 13:23:00 | 2 |
I tried using a for loop with an ifelse statement but that didn't work.