I have the following part of my data:
test <- wrapr::build_frame(
"date_time" , "automatic", "validate" |
"2020-12-01 00:34:58", "sombra" , "sombra" |
"2020-12-01 00:34:59", "organismo", "sombra" |
"2020-12-01 00:35:00", "partes" , "sombra" |
"2020-12-01 00:35:01", "sombra" , "sombra" |
"2020-12-01 00:36:02", "organismo", "sombra" |
"2020-12-01 00:36:03", "organismo", "partes" |
"2020-12-01 06:35:58", "sombra" , "sombra" |
"2020-12-01 06:35:59", "partes" , "sombra" |
"2020-12-01 06:36:00", "sombra" , "sombra" |
"2020-12-01 06:36:01", "sombra" , "partes" |
"2020-12-01 06:37:15", "organismo", "sombra" |
"2020-12-01 06:37:16", "partes" , "sombra" )
The column date_time corresponds to date (year, month and day) and time (hour, minute and second). This column has time values (not all here) for each second for every 3 minutes, after the third minute the data (next row) starts +-30 minutes later (again, not all data here).
I would create a column called cycle that gets the first date_time after this interval of +-30min and repeat this value until the next cycle of 3 minutes.
output desired for this data:
wrapr::build_frame(
"date_time" , "automatic", "validate", "cycle" |
"2020-12-01 00:34:58", "sombra" , "sombra" , "2020-12-01 00:34:58" |
"2020-12-01 00:34:59", "organismo", "sombra" , "2020-12-01 00:34:58" |
"2020-12-01 00:35:00", "partes" , "sombra" , "2020-12-01 00:34:58" |
"2020-12-01 00:35:01", "sombra" , "sombra" , "2020-12-01 00:34:58" |
"2020-12-01 00:36:02", "organismo", "sombra" , "2020-12-01 00:34:58" |
"2020-12-01 00:36:03", "organismo", "partes" , "2020-12-01 00:34:58" |
"2020-12-01 06:35:58", "sombra" , "sombra" , "2020-12-01 06:35:58" |
"2020-12-01 06:35:59", "partes" , "sombra" , "2020-12-01 06:35:58" |
"2020-12-01 06:36:00", "sombra" , "sombra" , "2020-12-01 06:35:58" |
"2020-12-01 06:36:01", "sombra" , "partes" , "2020-12-01 06:35:58" |
"2020-12-01 06:37:15", "organismo", "sombra" , "2020-12-01 06:35:58" |
"2020-12-01 06:37:16", "partes" , "sombra" , "2020-12-01 06:35:58" )
Thanks all