I'm a relative novice in R and am struggling with the following. I have one dataframe with a column of CO2 concentrations measured every second and a column with date-time (POSIXct), and a second dataframe with "start" and "stop" date-time. What I would like to do is assign a grouping variable (e.g. ascending numbers) in a new column to the dataframe with the CO2 concentrations based on the start/stop times of the second dataframe.
For example: start = 13:30 stop=13:33, so all the measured CO2 concentrations get grouping variable '1' if they fall in between the start/stop time.
As there is time between the first row of start/stop times and the second row, there are also many CO2 measurements which should get "NA" as the grouping variable.
Here is a subset of the start/stop data:
times <- structure(list(Start = structure(c(1591266360, 1591266960), class = c("POSIXct", "POSIXt"), tzone = ""), Stop = structure(c(1591266540, 1591267140 ), class = c("POSIXct", "POSIXt"), tzone = "")), row.names = 1:2, class = "data.frame")
And as the dataframe of the CO2 concentrations is rather large I've put the output in a text file: CO2 dataframe subset.
This is the first time asking a question here (as most of my previous questions were already asked before), so I apologise in advance if things are unclear.